I have a excel file it contains some of hiding rows which i don’t need them to imported into database, How can i get rid of these hiding rows by using function of ExportDataTableAsString?
Well, yes, when you use ExportDataTableAsString() method, the hidden rows would be also exported to the data table. I think for your need, you need to delete those hidden rows or move them to other place/worksheet before exporting to fill the data table. See the sample code below for your reference:
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(@“e:\test2\import1.xlsx”);
Aspose.Cells.Worksheet worksheet = workbook.Worksheets;
for (int i = 0; i < worksheet.Cells.MaxRow; i++)
DataTable dt = worksheet.Cells.ExportDataTableAsString(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1, false);
Hopefully, it will work for your need accordingly.
Workbook book = new Workbook(“C:\temp\hiddenrows.xlsx”);
int sheetindex = book.Worksheets.Add();
Worksheet sheet = book.Worksheets[sheetindex];
Cells cells = book.Worksheets.Cells;
int j = 0;
for (int i = 0; i < cells.Rows.Count; i++)
sheet.Cells.CopyRow(cells, i, j++);
DataTable table = sheet.Cells.ExportDataTableAsString(0, 0, sheet.Cells.MaxRow, sheet.Cells.MaxColumn);
i am sorry to tell you that i am using the old version of 4.7 now, it doesn’t have IsHidden property. Would you please help me on this again?
Well, I think may try to find the method like e.g use Cells.GetRowHeight() method to check if it gives you “0”, then the row must be hidden. The method should be there in your older version that you are using.
if (worksheet.Cells.GetRowHeight(i) == 0)