Visualizing cumulative trends over time is a common requirement in business reporting. An Area Stacked chart helps you illustrate how individual data series contribute to a total value while preserving the visual impact of area charts. In this guide, you’ll learn how to create an Area Stacked chart in Excel using C# with Aspose.Cells for .NET. The complete, ready‑to‑run code sample demonstrates data preparation, chart creation, styling, and saving the workbook.
This article covers the following topics:
- C# Excel Library to Create Area Stacked Charts
- Create an Area Stacked Chart in Excel using C#
- Get a Free License
- Free Resources
- Conclusion
- See Also
C# Excel Library to Create Area Stacked Charts
Aspose.Cells for .NET is a powerful spreadsheet library that lets developers generate, manipulate, and render Excel files without Microsoft Office. It offers a rich API for working with worksheets, cells, formulas, and all chart types—including the Area Stacked chart.
Key advantages of using Aspose.Cells for .NET:
- Comprehensive API – Access every Excel feature programmatically.
- Advanced Chart Support – Create and customize 100+ chart types.
- High Performance – Process large workbooks efficiently.
- Multiple Formats – Save to XLSX, XLS, CSV, PDF, PNG, and more.
Getting Started
Download the library from the official releases page.
Install via NuGet:
PM> Install-Package Aspose.CellsNote: The NuGet package includes all necessary dependencies.
Create an Area Stacked Chart in Excel using C#
The following example builds a workbook that contains quarterly sales data for three products and visualizes the data as an Area Stacked chart.
Step‑by‑Step Implementation
- Create a
Workbookinstance. - Populate the first worksheet with sample data.
- Add an Area Stacked chart object.
- Configure series, titles, and axes.
- Save the workbook to a file.
Explanation of Key Elements
| Code Segment | Purpose |
|---|---|
ChartType.AreaStacked | Instructs Aspose.Cells to create an Area Stacked chart. |
chart.NSeries.Add("=Sheet1!$B$2:$B$5", true); | Adds a data series referencing the range for Product A. The true flag indicates that the series includes category (X‑axis) data from column A automatically. |
chart.CategoryAxis.Title.Text | Sets the X‑axis label (“Quarter”). |
chart.ValueAxis.Title.Text | Sets the Y‑axis label (“Sales (USD)”). |
chart.PlotArea.Area.Formatting | Demonstrates custom formatting of the chart’s plot area. |
Run the program, and you’ll obtain AreaStackedChart_Output.xlsx containing the chart shown below (when opened in Excel).
Get a Free License
To try Aspose.Cells without evaluation restrictions, obtain a temporary free license from the Aspose temporary‑license page. Applying the license removes the default watermark and unlocks the full API surface.
// Example: applying a temporary license
var license = new License();
license.SetLicense("Aspose.Total.lic"); // Path to your .lic file
Free Resources
Continue mastering Excel automation with these free resources:
- Developer’s Guide – https://docs.aspose.com/cells/net/
- Online Demo & 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
An Area Stacked chart is an effective way to visualise cumulative data trends. Using Aspose.Cells for .NET, you can generate such charts programmatically with just a few lines of C# code. The example above demonstrates data preparation, chart creation, styling, and export in a fully self‑contained, compile‑ready program.
If you need assistance, feel free to post questions on the Aspose.Cells forum.