This short tutorial guides on how to create a Treemap in Excel using Java. It will assist you to set the IDE, provide a programming tasks list, and share a sample code for a Tree map chart in Excel using Java. You will learn the process by adding hierarchical sample data and then creating a customized Treemap using this data.
Steps to Create a Tree Map using Java
- Add Aspose.Cells for Java to your project for creating a Treemap
- Import the required modules and classes from the library and load the license to avoid a watermark
- Create a Workbook, access the first sheet, set its name, and add sample hierarchical data with headers
- Decorate the tabular data by setting the outline borders if required
- Add a Treemap chart, get its access, set the title with font, and add a value range for the series data
- Set category data, flag for multilevel labels, and set flags for showing values and categories
- Set legend position and save the Excel file on the disk as an XLSX file
This sequence of steps explains the creation of Tree map chart in Excel using Java. Create a workbook, get a sheet, add sample hierarchical data, and create a Treemap chart on the same sheet. Set all the parameters of the chart and save the output file on the disk.
Code for Excel Treemap Chart using Java
The above code sample demonstrates the generation of a Treemap chart. You may create other types of charts using the ChartType enumerator. There are many other custom options that can be set in the Chart object to configure the output chart as per the requirements.
This code has demonstrated the process of working with a Treemap. To create a Sunburst chart, refer to the article on Create Sunburst chart in Excel using Java.