HTML
JPG
PDF
XML
XLSX
XLSX
Add a line in chart via C#
Native and high performance MS Excel creation programmatically using server side .NET APIs.
Adding a line in chart dynamically within running application is easy. In order to create variety of charts to spreadsheets from scratch without requiring MS Office, we’ll use
Aspose.Cells for .NET
API that offers different features for spreadsheets creation, manipulation and conversion using .NET platform. Aspose.Cells provides many flexible chart objects.
How to Add a Line in Charts via C#
It is easy for the developers to add a line in chart within running different reporting applications for data processing in just a few lines of code.
- Create Workbook class instance.
- Add some data to worksheet cells with the Cell object’s PutValue method. This will be used as the data source for the chart.
- Add a Chart to the worksheet by calling the Charts collection’s Add method, encapsulated in the Worksheet object.
- Access the new Chart object from the Charts collection by passing its index, specify the chart’s data source by calling Chart.SetChartDataRange .
- Calculate the chart position by calling Calculate method.
- Add a Line Shape by calling Chart.Shapes.AddShapeInChartByScale method.
- Set the line format
System Requirements
Just make sure that system have Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Windows Azure, Mono or Xamarin Platforms as well as development environment like Microsoft Visual Studio.
- Install from command line as
nuget install Aspose.Cells
or via Package Manager Console of Visual Studio withInstall-Package Aspose.Cells
. - Alternatively, get the offline MSI installer or all DLLs in a ZIP file from downloads