This article guides how to group rows in Excel using Java. It has the details to set the development environment, a list of steps to develop the application, and a sample code depicting how to create collapsible rows in Excel using Java. It will discuss the details of grouping the columns and ungrouping rows and columns for the existing grouping.
Steps for Grouping Rows in Excel using Java
- Setup the system for using Aspose.Cells for Java into your project
- Load the source Excel file using the Workbook class for grouping rows and columns
- Access the collection of sheets and get a reference to the first sheet
- Call the groupRows() method by providing the first index, last index, and flag to hide
- Repeat the same process for columns using the groupColumns() method if required
- Save the resultant Workbook
The above steps describe the process to group columns in Excel using Java. Commence the process by loading the Excel file, accessing the sheet collection, and getting a reference to the first sheet. Invoke the groupRows() and groupColumns() method to create collapsible rows and columns.
Code to Create Collapsible Rows in Excel
This sample code demonstrates how to group columns in Excel using Java. You may use ungroupRows() and ungroupColumns() by providing the start and end index. You may also add multiple groupings within an existing group.
This article has taught us how to group rows in Excel with expand collapse using Java. To autofit rows and columns, refer to the article on Autofit rows and columns in Excel using Java.