Visualizing data that combines categorical proportions with absolute values often calls for a PieBar chart—a combination of a pie chart and a bar chart displayed together. With Aspose.Cells for .NET you can create such hybrid charts programmatically in just a few lines of code. This guide walks you through the process, explains the key API members, and provides a complete, compile‑ready C# example.
This article covers the following topics:
- C# Excel Library to Create PieBar Charts
- Create a PieBar Chart in Excel using C#
- Get a Free License
- PieBar Chart Excel: Free Resources
- Conclusion
- See Also
C# Excel Library to Create PieBar Charts
Aspose.Cells for .NET is a comprehensive Excel manipulation library that enables developers to create, edit, and render Excel files without Microsoft Excel installed. It provides first‑class support for all native Excel chart types, including combination charts such as PieBar (a pie chart combined with a bar chart).
Key advantages of using Aspose.Cells for this scenario:
- Full API control – Create charts, set series types, and customize axes programmatically.
- No COM interop – Works on any .NET platform (Windows, Linux, macOS) and in headless environments.
- High performance – Handles large workbooks and data sets with minimal memory overhead.
- Multiple output formats – Save the result as XLSX, PDF, PNG, or other supported formats.
Getting started is straightforward:
Download the latest release from the Aspose.Cells releases page.
Install the NuGet package:
PM> Install-Package Aspose.Cells
Create a PieBar Chart in Excel using C#
Below is a complete, ready‑to‑run C# example that demonstrates how to:
- Populate a worksheet with sample data.
- Add a Pie series (primary axis) to represent percentages.
- Add a Bar series (secondary axis) to show absolute values.
- Combine the two series in a single chart area, resulting in a PieBar chart.
- Save the workbook to an XLSX file (or any other format you require).
Explanation of the key steps
| Step | What it does | Important API members |
|---|---|---|
| 1‑2 | Creates a workbook and fills it with sample data. | Workbook, Worksheet, Cells |
| 3 | Adds a chart object whose base type is PieBar. This gives us a chart container that can host multiple series of different types. | Worksheet.Charts.Add, ChartType.Pie |
| 4 | Inserts the pie series that visualises Revenue as a share of the total. | Chart.NSeries.Add, Chart.NSeries[].Type = ChartType.Pie |
| 5 | Inserts the bar series that visualises Units Sold on a secondary axis, achieving the classic PieBar combination. | Chart.NSeries[].Type = ChartType.Bar, PlotOnSecondAxis = true |
| 6‑7 | Fine‑tunes axis titles, legend placement, and data label display for a professional look. | Chart.ValueAxis, Chart.SecondValueAxis, Chart.Legend, DataLabels |
| 8 | Saves the workbook. The result can be opened in Microsoft Excel, Google Sheets, or any other spreadsheet viewer. | Workbook.Save |
You can change the output format simply by altering the file extension in Workbook.Save. For example, use "PieBarChart_Output.pdf" to generate a PDF file.
Get a Free License
Aspose.Cells requires a license for full functionality. You can obtain a temporary free license for evaluation purposes:
Visit the Aspose temporary license page.
Fill out the short form and click Get License.
Download the
Aspose.Total.licfile and place it in your project folder.Load the license at the start of your application:
var license = new Aspose.Cells.License(); license.SetLicense("Aspose.Total.lic");
PieBar Chart Excel: Free Resources
- Developer’s Guide – https://docs.aspose.com/cells/net/
- Free Online Apps – https://products.aspose.app/cells/family
- API Reference – https://reference.aspose.com/cells/net/
- How‑to Articles – https://blog.aspose.com/categories/aspose.cells-product-family/
Conclusion
This article demonstrated how to create a PieBar chart—a powerful hybrid visualization that combines the proportional insight of a pie chart with the quantitative clarity of a bar chart—using Aspose.Cells for .NET. The provided sample program can be adapted to any data set, allowing you to embed professional‑grade charts directly into your Excel automation workflows.
If you encounter any issues or have further questions, feel free to visit the Aspose.Cells community forum for support.