This tutorial assists on how to create an Excel chart using C# REST API. You will learn how to add a graph in Excel using C# REST Interface with a .NET-based Cloud SDK. It will expose all the necessary properties and methods required to perform this task online.
Prerequisite
- Create an account and get API credentials for adding a chart
- Download Aspose.Cells Cloud SDK for Dotnet to create a graph
- Setup C# project with the above SDK
Steps for Inserting Graph in Excel using C# Low Code API
- Create an instance of the CellsApi using a client ID, client secret, and API base URL
- Specify the Excel file name that will be uploaded
- Send a request to upload the specified local Excel file to the Aspose Cloud storage
- Prepare a request to add a pie chart to a specific worksheet using a defined cell area
- Use the API for adding a chart with the PutWorksheetChart() method to the uploaded Excel file stored in the cloud
- Request the modified Excel file containing the new chart from the cloud storage
- Save the downloaded file stream to a new file on the local system
These steps summarize how to put chart in Excel using C# Low Code API. Commence the process by uploading an Excel file to Aspose Cloud, adding a pie chart to a specified worksheet using a defined data range and position, and then downloading the updated file. The modified file is saved locally for further use.
Code to Add Pie Chart in Excel using C# REST Interface
This sample code has demonstrated the process of how to create a graph on Excel using C# REST API. You may create other types of charts by setting the desired value in the charType property. For adding multiple charts, create the desired requests and execute them in a loop for creating the graphs in the uploaded worksheet.
This article has taught us the process of creating a chart. For adding a formula in an Excel file, refer to the article on Adding Excel formula using C# REST API.