I have a excel work sheet with some hidden columns.I want top know the column type is hidden or not or i need to read only the unhide columns in the workksheet
Well, you may use Column.IsHidden API to know if a column is hidden or not.
See a code segment for reference.
//You code goes here for creating/opening Workbook, worksheet/cells etc.
bool isColHidden = false;
for (int i = 0; i < 10; i++)
isColHidden = true;
// …Your code goes here.
How can you ExportDataTableAsString() method to read only the unhide columns and skip the hide columns
I am afraid the ExportDataTableAsString() method just works the same way as Copy/Paste in MS Excel. If you copy a range of cells (which has some hidden cols/rows in it) and past it onto some other location, the hidden data in cols/rows also gets pasted on the destination, so does the ExportDataTableAsString or ExportDataTable() method. I think you need to adopt some workaround for your needs. See the code segment below with template file(attached). I have deleted the hidden columns first then I exported the data to DataTable, it works fine accordingly now. The output file is also attached here.
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(@“e:\test2\Book1Exp.xlsx”);
Aspose.Cells.Worksheet worksheet = workbook.Worksheets;
for (int i = 0; i < worksheet.Cells.MaxDataColumn; i++)
DataTable dt = worksheet.Cells.ExportDataTableAsString(0, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1, false);
Aspose.Cells.Worksheet worksheet2 = workbook.Worksheets;
worksheet2.Cells.ImportDataTable(dt, true, “A1”);
Hope, this helps you.