分组、取消分组行和列
Contents
[
Hide
]
介绍
在 Microsoft Excel 文件中,您可以为数据创建一个大纲,以便通过单击鼠标来显示和隐藏详细信息级别。
点击大纲符号、1、2、3、+ 和 - 以仅快速显示为工作表中的部分提供摘要或标题的行或列,或者您可以使用这些符号来查看单个摘要或标题下的详细信息。
行列分组管理
Aspose.Cells提供了一个类,工作簿表示 Microsoft Excel 文件。这工作簿类包含一个工作表允许访问 Excel 文件中每个工作表的集合。工作表由工作表班级。这工作表类提供了一个细胞代表工作表中所有单元格的集合。
这细胞collection 提供了多种方法来管理工作表中的行或列,下面将详细讨论其中的一些方法。
分组行和列
可以通过调用组行和组列的方法细胞收藏。这两种方法都采用以下参数:
- 第一行/列索引,组中的第一行或第一列。
- 最后一行/列索引,组中的最后一行或最后一列。
- is hidden,布尔型参数,指定分组后是否隐藏行/列。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleGroupingUngroupingRowsAndColumns = dirPath->StringAppend(new String("sampleGroupingUngroupingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputGroupingUngroupingRowsAndColumns = outPath->StringAppend(new String("outputGroupingUngroupingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleGroupingUngroupingRowsAndColumns); | |
//Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
//Grouping first seven rows and first four columns | |
worksheet->GetICells()->GroupRows(0, 6, true); | |
worksheet->GetICells()->GroupColumns(0, 3, true); | |
//Save the Excel file. | |
workbook->Save(outputGroupingUngroupingRowsAndColumns); |
群组设置
Microsoft Excel 允许您配置组设置以显示:
- 详细信息下方的汇总行。
- 详细信息右侧的摘要列。
取消分组行和列
要取消分组任何已分组的行或列,请调用细胞收藏的解组行和取消组合列方法。两种方法都有两个参数:
- 第一行或列索引,要取消分组的第一行/列。
- 最后一行或最后一列索引,要取消分组的最后一行/列。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input excel file | |
StringPtr sampleGroupingUngroupingRowsAndColumns = dirPath->StringAppend(new String("sampleGroupingUngroupingRowsAndColumns.xlsx")); | |
//Path of output excel file | |
StringPtr outputGroupingUngroupingRowsAndColumns = outPath->StringAppend(new String("outputGroupingUngroupingRowsAndColumns.xlsx")); | |
//Read input excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleGroupingUngroupingRowsAndColumns); | |
//Accessing the second worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(1); | |
//UnGroup first seven rows and first four columns | |
worksheet->GetICells()->UngroupRows(0, 6); | |
worksheet->GetICells()->UngroupColumns(0, 3); | |
//Save the Excel file. | |
workbook->Save(outputGroupingUngroupingRowsAndColumns); |