从工作表中导出可见行数据
Contents
[
Hide
]
您可以使用Aspose.Cells将工作表中的数据导出到数据表。有时,您只想导出可见行的数据。Aspose.Cells提供了一种实现此目的的方法。使用ExportTableOptions.PlotVisibleRows来指定您只想导出可见行的数据。
此示例显示了如何从以下工作表中导出数据。第5、6和7行被隐藏。
工作表中的示例数据,第5、6和7行被隐藏 |
---|
![]() |
将数据导出到数据表后,使用Worksheet.Cells.ExportDataTable()方法和ExportTableOptions.PlotVisibleRows选项,它看起来像这样。隐藏行被绘制为空行
将隐藏行导出到数据表中作为空行 |
---|
![]() |
This file contains 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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
string filePath = dataDir+ "aspose-sample.xlsx"; | |
// Load the source workbook | |
Workbook workbook = new Workbook(filePath); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Specify export table options | |
ExportTableOptions exportOptions = new ExportTableOptions(); | |
exportOptions.PlotVisibleRows = true; | |
exportOptions.ExportColumnName = true; | |
// Export the data from worksheet with export options | |
DataTable dataTable = worksheet.Cells.ExportDataTable(0, 0, 10, 4, exportOptions); |