While am trying to convert cells to exportDataTable am getting exception as
Input string was not in a correct format.Couldn't store in Column3 Column. Expected type is Double.
am trying to export all the cell values into a datatable
below url am trying to export into datatable
http://www.hkex.com.hk/eng/market/sec_tradinfo/isincode/documents/isinsehk.xls
and
Is there any method to convert excel to an .CSV format
Thanks in advance
This message was posted using Aspose.Live 2 Forum
Hi,
Well, there is some missing or invalid values for some
columns you are exporting. If you look your data in the sheet, actually
there are two tables e.g A18:C21 and other table is: A24:C_; For your
information, the data type for ExportDataTable method is determined by
the first value of the column, suppose for your third column “HK Stock
Code” , its data type is double based on the first value, but there is
no value given for C22 and C23 respectedly, so the exception will be
thrown.
For your need, you should do:
1) Export two data tables e.g A18:C21 and A24:C_ etc. separately.
2)
You may use ExportDataTableAsString method instead of ExportDataTable
method, using the ExportDataTableAsString method would export all the
data in string types, so you may change the line:
e.g
var dt = ws.Cells.ExportDataTable(19, 0, 60, 3);
to
var dt = ws.Cells.ExportDataTableAsString(19, 0, 60, 3);
To export the excel file as .CSV, you may simply Save the workbook to your desired format, e.g
wb.Save(“C:\book1.csv”, SaveFormat.CSV)
see the document for your complete reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/saving-files.html
Thank you