Visualizing hierarchical data with a Pyramid Bar chart can make your reports more engaging and easier to interpret. In this guide, you’ll discover how to create a Pyramid Bar chart in an Excel workbook programmatically using C# and Aspose.Cells for .NET. The example demonstrates adding data, inserting a Pyramid Bar chart, customizing its appearance, and saving the file in various formats.
This article covers the following topics:
- C# Excel Library to Create Pyramid Bar Charts
- Create a Pyramid Bar Chart in Excel using C#
- Free License
- Additional Resources
- Conclusion
- See Also
C# Excel Library to Create Pyramid Bar Charts
Aspose.Cells for .NET is a robust Excel manipulation library that enables developers to create, modify, and format Excel files without requiring Microsoft Excel. It provides a comprehensive API for working with worksheets, cells, formulas, and a wide variety of chart types—including the Pyramid Bar chart.
Key advantages of using Aspose.Cells for .NET:
- Rich Chart Support – Over 50 chart types, including Pyramid Bar, Funnel, Waterfall, and more.
- Zero Dependency – No need for Excel installation on the server.
- High Performance – Efficient handling of large workbooks and datasets.
- Multiple Export Formats – Save to XLSX, PDF, PNG, HTML, and many others.
Getting started is straightforward:
Download the latest release from the Aspose.Cells releases page.
Install the NuGet package:
PM> Install-Package Aspose.CellsAdd
using Aspose.Cells;andusing Aspose.Cells.Charts;to your C# source file.
Create a Pyramid Bar Chart in Excel using C#
Below is a complete, ready‑to‑run C# console application that demonstrates how to:
- Create a new workbook.
- Populate sample hierarchical data.
- Insert a Pyramid Bar chart.
- Apply basic formatting (title, legend, axis labels).
- Save the workbook as an XLSX file.
Explanation of the Code
| Step | Purpose |
|---|---|
| 1 | Instantiates a blank workbook and references the first worksheet. |
| 2 | Populates the worksheet with a header row and sample sales data for four regions across four quarters. |
| 3 | Adds a PyramidBar chart to a defined area on the sheet (rows 7‑25, columns A‑J). |
| 4 | Links the chart to the data range (B2:E5) and sets the category (region) data (A2:A5). Each column becomes a separate series (Q1‑Q4). |
| 5 | Applies titles to the chart and axes and formats the value axis to display currency. |
| 6 | Saves the workbook as PyramidBarChart_Output.xlsx. |
Run the program, open the generated file in Excel, and you’ll see a Pyramid Bar chart that visually compares quarterly sales across regions.
Get a Free License
Aspose.Cells offers a temporary free license that removes evaluation watermarks and unlocks the full feature set. Obtain it from the Aspose temporary license page. Apply the license in your code before any workbook manipulation:
License license = new License();
license.SetLicense("Aspose.Total.lic"); // Path to your temporary license file
Pyramid Bar Chart Excel: Free Resources
Take advantage of these additional resources to deepen your expertise with Aspose.Cells:
- Developer’s Guide – https://docs.aspose.com/cells/net/
- Online Spreadsheet Tools – 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/
- Sample Repository – https://github.com/aspose-cells/Aspose.Cells-for-.NET
Conclusion
Creating a Pyramid Bar chart with Aspose.Cells for .NET is straightforward and requires only a few lines of code. The library’s rich charting capabilities let you generate professional, export‑ready visualizations without relying on Microsoft Excel. Experiment with additional formatting options—such as data labels, custom colors, and trendlines—to tailor the chart to your specific reporting needs.
If you have questions or need assistance, visit the Aspose.Cells support forum for help from our community and product experts.