Visualizing hierarchical data with a Treemap chart makes complex information easy to understand at a glance. In this article you will learn how to create a Treemap chart in Excel using C# and Aspose.Cells for .NET. The guide includes a complete, runnable code sample, tips for customizing the chart appearance, and resources for getting started quickly.
This article covers the following topics:
- C# Excel Library to Create Treemap Charts
- Create a Treemap Chart in Excel using C#
- Get a Free License
- Treemap Chart Excel: Free Resources
- Conclusion
- See Also
C# Excel Library to Create Treemap Charts
Aspose.Cells for .NET is a comprehensive Excel manipulation library that allows developers to create, edit, and render Excel files without Microsoft Office. It supports a wide range of chart types, including the Treemap chart which is ideal for visualizing hierarchical structures such as sales by region, product categories, or organisational charts.
Key benefits of using Aspose.Cells for .NET:
- Rich API – Full access to workbook, worksheet, cell, and chart objects.
- High Performance – Works efficiently with large workbooks and data sets.
- No External Dependencies – Operates on any platform that supports .NET.
- Multiple Export Formats – Save to XLSX, XLS, CSV, PDF, PNG, and more.
Getting started is straightforward:
Download the library from the Aspose.Cells releases page.
Install the NuGet package:
PM> Install-Package Aspose.Cells
Create a Treemap Chart in Excel using C#
How to Build a Treemap Chart
The following example demonstrates how to:
- Create a new workbook.
- Populate the worksheet with hierarchical data.
- Add a Treemap chart.
- Configure series, titles, and formatting.
- Save the workbook to an Excel file.
Note – The code is fully self‑contained and can be compiled with .NET 6.0 or later.
Explanation of key steps
| Step | Purpose |
|---|---|
| 1 | Instantiates a new Workbook and obtains the first worksheet. |
| 2 | Populates the worksheet with hierarchical sales data. The first row contains headers. |
| 3 | Adds a chart of type ChartType.Treemap. The chart’s position and size are defined by the row/column indices passed to Charts.Add. |
| 4 | Adds a single series that uses Sales as the value range (E2:E7) and the hierarchy (A2:D7) as the category data. |
| 5 | Enables data labels to show both the value and the category name, and activates color variation based on the sales amount. |
| 6 | Saves the workbook as an XLSX file. The generated file can be opened in Excel to view the Treemap. |
Get a Free License
Explore Aspose products with a temporary free license. Visit the temporary license page to obtain a key that removes evaluation restrictions, enabling you to develop and test without limitations.
Treemap Chart Excel: Free Resources
Enhance your Excel automation skills with these free resources:
- Developer’s Guide – Comprehensive documentation for Aspose.Cells: https://docs.aspose.com/cells/net/
- Online Apps – Try chart creation directly in the browser: https://products.aspose.app/cells/family
- API Reference – Detailed class and method descriptions: https://reference.aspose.com/cells/net/
- How‑To Articles – Practical examples and best practices: https://blog.aspose.com/categories/aspose.cells-product-family/
Conclusion
Creating a Treemap chart with Aspose.Cells for .NET is straightforward and requires only a few lines of code. The library handles data hierarchy, chart rendering, and file output without the need for Microsoft Office. By following the example above you can quickly generate professional Treemap visualizations for financial reports, sales analysis, or any hierarchical data set.
If you encounter any issues or have questions, feel free to visit our free support forum at https://forum.aspose.com/c/cells/9.