Visualizing proportional data is a common requirement for business reports, dashboards, and presentations. In this article, you will learn how to create a Pie chart in an Excel workbook using C# with Aspose.Cells for .NET. The guide provides a clear, step‑by‑step walkthrough and complete, ready‑to‑run code samples that you can integrate into any .NET application.

This article covers the following topics:

C# Excel Library to Create Pie Charts

Aspose.Cells for .NET is a powerful, feature‑rich library that enables developers to create, modify, and render Excel files without Microsoft Office. The library provides a comprehensive API for chart creation, including full support for Pie, 3‑D Pie, Doughnut, and many other chart types.

Key benefits of using Aspose.Cells for creating Pie charts:

  • Full Control Over Chart Elements – titles, legends, data labels, colors, and explosion settings.
  • No Dependency on Excel – run on servers, cloud services, or any environment where .NET is supported.
  • High Performance – efficient handling of large data sets.
  • Multiple Output Formats – save as XLSX, PDF, PNG, JPEG, and more.

To start using Aspose.Cells, install the NuGet package:

PM> Install-Package Aspose.Cells

Create a Simple Pie Chart in Excel using C#

The following example demonstrates how to create a basic Pie chart that visualizes market share data.

Explanation of key steps

StepPurpose
1Create a fresh Workbook and obtain the default worksheet.
2Fill the sheet with product names and corresponding share values.
3Add a chart of type ChartType.Pie. The four numeric arguments define the top‑left and bottom‑right corners of the chart area (row, column).
4Assign a meaningful title to the chart.
5Bind the series to the numeric data (B2:B5) and categories (A2:A5).
6Enable data labels and configure them to display both category names and percentages.
7Persist the workbook to disk.

Running the code creates SimplePieChart_Output.xlsx containing a clear Pie chart that displays each product’s market share.

Create an Exploded Pie Chart with Custom Colors

Sometimes you need a more vivid presentation—such as an exploded slice or custom segment colors. The example below shows how to achieve this.

Highlights

  • The chart type ChartType.PieExploded creates a pie with an exploded default slice; individual slice explosion is controlled via the Explosion property of each point.
  • Custom colors are applied through Area.ForegroundColor.
  • Data labels are enabled per point to display both category names and percentages.
  • The legend is positioned on the right side of the chart for better readability.

The resulting ExplodedPieChart_Output.xlsx displays a visually striking pie chart with custom-colored, exploded slices.

Get a Free License

Explore Aspose.Cells with a temporary free license to unlock the full functionality of the library. Visit the temporary license page to obtain your free license file and follow the integration steps described in the official documentation.

Pie Chart Excel: Free Resources

Take advantage of additional learning material to master Excel automation with Aspose.Cells:

Conclusion

In this post we demonstrated how to create both a basic Pie chart and an exploded, color‑customized Pie chart using Aspose.Cells for .NET. By leveraging the library’s rich charting API you can generate professional‑looking visualizations without relying on Microsoft Excel, making your .NET applications more portable and scalable.

If you need further assistance, feel free to ask questions on the Aspose.Cells support forum.

See Also