We have code that uses the .ImportDataTableFormat() method to create a workbook from datatables.
public Workbook BuildReport(DataSet reportData)
{
var workBook = SetupWorkBook();
workBook.Worksheets.Add();
workBook.Worksheets[0].Cells.ImportDataTable(reportData.Tables[0], true, "A1");
workBook.Worksheets[1].Cells.ImportDataTable(reportData.Tables[1], false, "A1");
ApplyWorksheetFormatting(workBook.Worksheets[0]);
ApplyWorksheetFormatting(workBook.Worksheets[1]);
//Set the style and format of col with index 1 to date
Style style = workBook.CreateStyle();
StyleFlag flag = new StyleFlag();
style.Number = 14;
flag.NumberFormat = true;
Column col = workBook.Worksheets[0].Cells.Columns[1];
col.ApplyStyle(style, flag);
**workBook.Worksheets[0].Cells.ConvertStringToNumericValue();**
return workBook;
}
The line in bold seems to set the format of all cells correctly and achieves what we need. We only need this to be applied to specific columns in the workbook. The ConvertStringToNumericValue() method cannot be applied on a column, only all cells in the workbook.
Is there a way this can be applied to a column or cells in a column?