Export Visible Rows Data from Worksheet
Contents
[
Hide
]
You can export data from worksheets into data tables using Aspose.Cells. Sometimes you want to export the data of visible rows only. Aspose.Cells provides a way to achieve this. Use the ExportTableOptions.PlotVisibleRows to specify that you want to export visible rows data only.
This example shows how to export data from the following worksheet. Rows 5, 6 and 7 are hidden.
Sample data in worksheet, rows 5, 6 and 7 are hidden |
---|
![]() |
Once the data is exported to a data table using the Worksheet.Cells.ExportDataTable() method with the ExportTableOptions.PlotVisibleRows option, it will look like this. Hidden rows are plotted as blank rows
Hidden rows are exported to the data table as blank rows |
---|
![]() |
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); |