Visualizing hierarchical data with a Pyramid Bar Stacked chart can make your reports more compelling and easier to understand. In this article, you’ll learn how to create such a chart in Excel using C# and Aspose.Cells for .NET. The guide includes two complete, ready‑to‑run code snippets:

  • Basic creation – build a Pyramid Bar Stacked chart from scratch.
  • Updating an existing built‑in chart – change the chart type of a pre‑existing chart to Pyramid Bar Stacked.

Whether you are generating financial dashboards, inventory reports, or any dataset that benefits from a pyramid‑style stacked bar visual, the steps below will get you there quickly.


Topics Covered


C# Excel Library to Create Pyramid Bar Stacked Charts

Aspose.Cells for .NET is a powerful, dependency‑free library that enables developers to create, modify, and render Excel files programmatically. Its extensive API covers every Excel feature, including the full range of chart types such as PyramidBarStacked.

Key benefits of using Aspose.Cells for chart generation:

FeatureBenefit
Comprehensive APIDirect access to workbook, worksheet, cells and chart objects.
High PerformanceHandles large data sets with minimal memory footprint.
No Excel RequiredOperates completely on the server‑side without Microsoft Office.
Multiple Output FormatsSave as XLSX, PDF, HTML, PNG, JPEG, etc.
Rich CustomisationFine‑tune series, axes, legends, colors, markers, and more.

Getting Started

  1. Download the latest release from the Aspose.Cells downloads page.

  2. Install the NuGet package:

    PM> Install-Package Aspose.Cells
    
  3. Add a reference to Aspose.Cells in your C# project.

Now you are ready to start building Pyramid Bar Stacked charts.

Create a Pyramid Bar Stacked Chart in Excel using C#

1️⃣ Basic Pyramid Bar Stacked Chart

The following example creates a new workbook, populates sample data, adds a Pyramid Bar Stacked chart, customises its appearance, and saves the file as PyramidBarStackedChart.xlsx.

Explanation of key steps

StepWhat it does
1Creates a new Workbook and references the first Worksheet.
2Writes header and sample data for four regions across four quarters.
3Adds a Chart of type ChartType.PyramidBarStacked.
4Adds four series – one for each quarter – using the NSeries.Add method.
5Assigns custom colors, axis titles, and moves the legend to the right.
6Saves the workbook to an XLSX file.

Run the program and open PyramidBarStackedChart.xlsx – you will see a pyramid‑shaped stacked bar chart that clearly compares quarterly sales across the four regions.

Get a Free License

Aspose.Cells requires a license for full functionality. To evaluate the library without restrictions, obtain a temporary free license from the Aspose temporary license page. Apply the license as shown below:

// Apply the temporary license (once per application start)
var license = new Aspose.Cells.License();
license.SetLicense("Aspose.Total.lic"); // Path to your .lic file

Free Resources


Conclusion

Creating a Pyramid Bar Stacked chart with Aspose.Cells for .NET is straightforward: populate your data, add a chart of type ChartType.PyramidBarStacked, configure series and aesthetics, and save the workbook. Whether you start from a fresh workbook or modify an existing template, the library provides a clean, server‑side solution that works without Microsoft Excel installed.

Feel free to experiment with additional customisations—data labels, gradient fills, or exporting the chart as an image. For any questions, the Aspose community and support forums are ready to help.


See Also