Hello,
I have a spreadsheet which I use ExportDataTable method to export to a data table. Then, I try to bulkcopy my data to the database but having trouble because of the datatype mismatch. SQL db does not have a “double” datatype. How can I check if a cell is of type double and convert it to decimal?
A couple things I tried…
- apply a custom style (style.custom = ‘0.00’) before I export to datatable but it still ends up as double
- attempt to loop through each cell and set the style:
Cells cells = worksheet.Cells;
int mRow = cells.MaxDataRow;
int mCol = cells.MaxDataColumn;
for (int i = 0; i <= mRow; i++)
{
for (int j = 0; j <= mCol; j++)
{
Aspose.Cells.Cell cell = cells[i, j];
if (cell.Value != null)
{
System.Type type = cell.GetType(); //this does not give me data type for the number
//not sure what is the proper thing to do here to get the number data type to convert it to decimal
}
}
}