Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
In a Microsoft Excel file, you can create an outline for the data to allow you to show and hide levels of detail with a single mouse click.
Click the Outline Symbols, 1, 2, 3, + and – to quickly display only the rows or columns that provide summaries or headings for sections in a worksheet, or you can use the symbols to see details under an individual summary or heading, as shown below in the figure:
| Grouping Rows and Columns. |
|---|
![]() |
Aspose.Cells provides a class, Workbook that represents a Microsoft Excel file. The Workbook class contains a WorksheetCollection that allows access to each worksheet in the Excel file. A worksheet is represented by the Worksheet class. The Worksheet class provides a Cells collection that represents all cells in the worksheet.
The Cells collection provides several methods to manage rows or columns in a worksheet; a few of these are discussed below in more detail.
It is possible to group rows or columns by calling the groupRows(number, number, boolean) and groupColumns(number, number) methods of the Cells collection. Both methods take the first two parameters; groupRows additionally takes a Boolean parameter that specifies whether to hide rows/columns after grouping. The parameters are:
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "book1.xls");
// Reading the Excel file into a buffer
const fs = require("fs");
const fileContent = fs.readFileSync(filePath);
// Opening the Excel file through the buffer
const workbook = new AsposeCells.Workbook(fileContent);
// Accessing the first worksheet in the Excel file
const worksheet = workbook.getWorksheets().get(0);
// Grouping first six rows (from 0 to 5) and making them hidden by passing true
worksheet.getCells().groupRows(0, 5, true);
// Grouping first three columns (from 0 to 2) and making them hidden by passing true
worksheet.getCells().groupColumns(0, 2, true);
// Saving the modified Excel file
workbook.save(path.join(dataDir, "output.xls"));
Microsoft Excel allows you to configure group settings for displaying:
Developers can configure these group settings using the getOutline() property of the Worksheet class.
It is possible to control whether summary rows are displayed below detail by setting the Outline class’s getSummaryRowBelow() property to true or false.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.xlsx");
// Loads the workbook which contains hidden external links
const workbook = new AsposeCells.Workbook(filePath);
const worksheet = workbook.getWorksheets().get(0);
// Grouping first six rows and first three columns
worksheet.getCells().groupRows(0, 5, true);
worksheet.getCells().groupColumns(0, 2, true);
// Setting SummaryRowBelow property to false
worksheet.getOutline().setSummaryRowBelow(false);
// Saving the modified Excel file
workbook.save(path.join(dataDir, "output.xls"));
Developers can also control displaying summary columns to the right of detail by setting the getSummaryColumnRight() property of the Outline class to true or false.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.xlsx");
// Loads the workbook which contains hidden external links
const workbook = new AsposeCells.Workbook(filePath);
const worksheet = workbook.getWorksheets().get(0);
// Grouping first six rows and first three columns
worksheet.getCells().groupRows(0, 5, true);
worksheet.getCells().groupColumns(0, 2, true);
worksheet.getOutline().setSummaryColumnRight(true);
// Saving the modified Excel file
workbook.save(path.join(dataDir, "output.xls"));
To ungroup any grouped rows or columns, call the Cells collection’s ungroupRows(number, number, boolean) and ungroupColumns(number, number) methods. Both methods take two parameters:
ungroupRows(number, number, boolean) has an overload that takes a Boolean third parameter. Setting it to true removes all grouped information; otherwise, only the outer‑group information is removed.
const path = require("path");
const fs = require("fs");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "book1.xls");
// Reading Excel file into buffer
const buffer = fs.readFileSync(filePath);
// Instantiating a Workbook object with file content
const workbook = new AsposeCells.Workbook(buffer);
// Accessing the first worksheet in the Excel file
const worksheet = workbook.getWorksheets().get(0);
// Ungrouping first six rows (from 0 to 5)
worksheet.getCells().ungroupRows(0, 5);
// Ungrouping first three columns (from 0 to 2)
worksheet.getCells().ungroupColumns(0, 2);
// Saving the modified Excel file
workbook.save(path.join(dataDir, "output.xls"));
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.