We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Opening worksheet with header row

Hi,


I am using ASPOSE to open a .xlsm file which contains header row. Is there a way to create data table from this .xlsm file excluding the header row?

I am using the following code to open and create data table.


Workbook uploadedWorkBook = new Workbook(FilePath);
Worksheet wsWorSheet = uploadedWorkBook.Worksheets[0];
TempDt = wsWorSheet.Cells.ExportDataTable(0, 0, wsWorSheet.Cells.MaxRow + 1, wsWorSheet.Cells.MaxColumn + 1);
TempDt.AcceptChanges();


Now the data table is exported with column names as column 1, column etc…
Can i export the data table with column names as say header 1, Header 2 etc?

Please help.


Hi,


Well, either you may include or exclude header row as column names for the datatable. You need choose the relevant overload of ExportDataTable() method. For example, you may use the following line of code to include the first/ header row as column names in the table:
e.g
Sample code:

TempDt = wsWorSheet.Cells.ExportDataTable(0, 0, wsWorSheet.Cells.MaxRow + 1, wsWorSheet.Cells.MaxColumn + 1, true); // put true for exportColumnName last parameter.

Thank you.