Visualizing proportional data such as market share, expense distribution or survey results is often best done with a Doughnut chart. In this article you will learn how to create a Doughnut chart in Excel using C# and Aspose.Cells for .NET. The guide provides two complete, ready‑to‑run code samples – a basic single‑series Doughnut chart and a multi‑series chart with custom colors and legend settings – so you can instantly integrate powerful visualizations into any .NET application.
This article covers the following topics:
- C# Excel Library to Create Doughnut Charts
- Create a Doughnut Chart in Excel using C#
- Free License
- Free Resources
- Conclusion
- See Also
C# Excel Library to Create Doughnut Charts
Aspose.Cells for .NET is a comprehensive Excel automation library that enables developers to create, modify, and render Excel files without Microsoft Office. It includes a rich charting API that supports all native Excel chart types, including the Doughnut chart.
Key capabilities that make Aspose.Cells the preferred choice for chart generation:
- Full Chart Type Support – From simple Column charts to advanced Waterfall and Doughnut charts.
- Fine‑Grained Customization – Control series types, colors, markers, data labels, legends, axes, and more.
- High Performance – Process large workbooks efficiently on server‑side environments.
- Cross‑Platform Compatibility – Works on .NET Framework, .NET Core, .NET 5/6/7+, and .NET Standard.
Getting Started
Download the latest Aspose.Cells for .NET binary from the releases page.
Install the NuGet package:
PM> Install-Package Aspose.CellsAdd a reference to
Aspose.Cellsin your C# project.
Now you are ready to create Doughnut charts programmatically.
Create a Doughnut Chart in Excel using C#
How to Create a Simple Single‑Series Doughnut Chart
The following example demonstrates the minimal steps required to add a Doughnut chart that shows the sales distribution across four product categories.
Explanation of key steps
| Step | Purpose |
|---|---|
| 2 | Fill the worksheet with category names and numeric values. |
| 3 | Add a chart of type ChartType.Doughnut. |
| 4 | Create a series that points to the numeric data range. |
| 5 | Link the series to the category (label) range. |
| 6 | Enable data labels that display percentages and adjust the hole size. |
| 7 | Persist the workbook to an XLSX file. |
Running the program generates DoughnutChart_Simple.xlsx containing a single‑series Doughnut chart similar to the screenshot below (the screenshot is omitted in this text‑only document).
How to Create a Multi‑Series Doughnut Chart with Custom Colors
A Doughnut chart can also contain multiple series. The example below builds a chart that shows quarterly expense distribution for three departments. Custom colors are applied to each series for better visual distinction.
What the code demonstrates
- Adding multiple series to a single Doughnut chart (each quarter is a series).
- Setting category data once per series so that the same labels are reused.
- Customizing border and fill colors for each series to improve readability.
- Enabling percentage data labels for every series.
- Positioning the legend on the right side of the chart.
When you run the program, the generated DoughnutChart_MultiSeries.xlsx will contain a Doughnut chart with three concentric rings, each representing a different quarter’s expenses.
Get a Free License
To try Aspose.Cells without any limitations, request a temporary free license from the Aspose temporary license page. The temporary license removes evaluation watermarks and allows unrestricted use for development and testing.
// Example of applying a temporary license programmatically
var license = new Aspose.Cells.License();
license.SetLicense("Aspose.Total.NET.lic"); // Path to your temporary .lic file
Doughnut Chart Excel: Free Resources
- Developer’s Guide – Comprehensive documentation and tutorials: https://docs.aspose.com/cells/net/
- Online Demo – Generate and preview Doughnut charts instantly: https://products.aspose.app/cells/family
- API Reference – Full reference for charting classes and members: https://reference.aspose.com/cells/net/
- How‑To Articles – Step‑by‑step guides for common tasks: https://blog.aspose.com/categories/aspose.cells-product-family/
Conclusion
Creating visually appealing Doughnut charts in Excel is straightforward with Aspose.Cells for .NET. The library’s fluent API lets you populate data, add charts, customize series colors, display percentages, and export the result to XLSX, PDF, or image formats—all without requiring Microsoft Office. By incorporating the provided code snippets into your projects, you can deliver professional, data‑driven visualizations quickly and reliably.
If you encounter any issues or have questions, feel free to visit the Aspose.Cells support forum for assistance.