Create Charts in Excel Spreadsheets using C#

create excel charts C#

Excel charts are used to visualize the data in spreadsheets. MS Excel supports a variety of charts such as line, bar, pie, doughnut, pyramid, bubble, etc. In this article, you will learn how to create charts in Excel files using C#.

C# API to Create Charts in Excel

In order to work with Excel charts, we’ll use Aspose.Cells for .NET. It is a powerful API that lets you implement Excel automation in .NET applications. Furthermore, it allows you create a variety of charts seamlessly. To use the API, you can either download the DLL or install it using NuGet.

Install-Package Aspose.Cells

Supported Excel Chart Types

Aspose.Cells for .NET provides a complete set of standard chart types. The list includes, but not limited to:

Chart TypesDescription
ColumnRepresents Clustered Column Chart
ColumnStackedRepresents Stacked Column Chart
Column100PercentStackedRepresents 100% Stacked Column Chart
Column3DClusteredRepresents 3D Clustered Column Chart
Column3DStackedRepresents 3D Stacked Column Chart
Column3D100PercentStackedRepresents 3D 100% Stacked Column Chart
Column3DRepresents 3D Column Chart
BarRepresents Clustered Bar Chart
BarStackedRepresents Stacked Bar Chart
Bar100PercentStackedRepresents 100% Stacked Bar Chart
Bar3DClusteredRepresents 3D Clustered Bar Chart
Bar3DStackedRepresents 3D Stacked Bar Chart
Bar3D100PercentStackedRepresents 3D 100% Stacked Bar Chart
LineRepresents Line Chart
LineStackedRepresents Stacked Line Chart
Line100PercentStackedRepresents 100% Stacked Line Chart
LineWithDataMarkersRepresents Line Chart with data markers
LineStackedWithDataMarkersRepresents Stacked Line Chart with data markers
Line100PercentStackedWithDataMarkersRepresents 100% Stacked Line Chart with data markers
Line3DRepresents 3D Line Chart
PieRepresents Pie Chart
Pie3DRepresents 3D Pie Chart
PiePieRepresents Pie of Pie Chart
PieExplodedRepresents Exploded Pie Chart
Pie3DExplodedRepresents 3D Exploded Pie Chart
PieBarRepresents Bar of Pie Chart
ScatterRepresents Scatter Chart
ScatterConnectedByCurvesWithDataMarkerRepresents Scatter Chart connected by curves, with data markers

For a complete list of supported Excel charts, visit this article.

Create Charts in Excel using C#

The following are the steps to create a chart in Excel using C#.

The following code sample shows how to create an Excel chart using C#.

create column chart in C#

Create a Line Chart in Excel using C#

In order to insert a line chart, you only need to specify the ChartType.Line type in Worksheet.Charts.Add() method. The rest of the steps will be the same as mentioned in the previous section.

The following code sample shows how to create a line chart in Excel using C#.

line chart in in Excel C#

Create a Pyramid Chart in Excel using C#

For adding a pyramid chart, simply pass ChartType.Pyramid type while adding the chart to the worksheet. The following are the steps to add a pyramid chart in Excel using C#.

The following code sample shows how to insert a pyramid chart in an Excel worksheet using C#.

create pyramid chart in Excel

To learn more about working with Excel charts, read this documentation article.

Get a Free API License

You can try Aspose.Cells for .NET without evaluation limitations by requesting a temporary license.

Conclusion

In this article, you have seen how to create charts in Excel worksheets using C#. Particularly, you have learned how to create column, line, and pyramid charts in Excel. Furthermore, you can also create other types of charts seamlessly using Aspose.Cells for .NET. For more details, visit the documentation of the API. In case you would have any queries, contact us via our forum.

See Also