表格和范围
Contents
[
Hide
]
介绍
有时您在 Microsoft Excel 中创建了一个表格,并且不想继续使用它附带的表格功能。相反,您想要看起来像桌子的东西。要在不丢失格式的情况下保留表格中的数据,请将表格转换为常规范围的数据。 Aspose.Cells 不支持表和列表对象的 Microsoft Excel 的此功能。
使用 Microsoft Excel
使用转换为范围在不丢失格式的情况下快速将表格转换为范围的功能。在 Microsoft Excel 2007/2010 中:
- 单击表格中的任意位置以确保活动单元格位于表格列中。
- 在设计选项卡,在工具分组,点击转换为范围.
表格转换为区域后,表格功能将不再可用。例如,行标题不再包含排序和筛选箭头,公式中使用的结构化引用(使用表名的引用)变成了常规单元格引用。
使用 Aspose.Cells
以下代码片段使用 Aspose.Cells 演示了相同的功能。
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 | |
// Instantiate a Workbook object and open an Excel file | |
intrusive_ptr<IWorkbook> workbook =Factory::CreateIWorkbook(dataDir_Tables->StringAppend(new String("sample.xlsx"))); | |
// Accessing the first worksheet in the Excel file | |
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0); | |
// Get the List objects collection in the first worksheet. | |
intrusive_ptr<IListObjectCollection> listObjects = worksheet->GetIListObjects(); | |
// Convert the first table/list object (from the first worksheet) to normal range | |
listObjects->GetObjectByIndex(0)->ConvertToRange(); | |
// Saving the Excel file | |
workbook->Save(dataDir_Tables->StringAppend(new String("ConvertTableToRange_out.xls"))); |