Posted 30 May 2023, 3:50 am EST
Hello Sushant,
Apologies for the delay in response.
You can set the AutoParse property of the Workbook to True to parse the String values to Numeric data.
Please find the attached sample demonstrating the same:
Workbook wb = new Workbook();
IWorksheet sheet = wb.Worksheets[0];
DataTable dt = new DataTable();
dt.Columns.Add("Col 1", typeof(Object));
dt.Rows.Add(new object[] { "12" });
dt.Rows.Add(new object[] { 35 });
dt.Rows.Add(new object[] { "12.7" });
dt.Rows.Add(new object[] { "Temp" });
dt.Rows.Add(new object[] { 15.2 });
IRange range = sheet.Range["A1:A5"];
int i = 0;
foreach (DataRow row in dt.Rows)
{
range.Cells[i].Value = row[0];
range.Cells[i].NumberFormat = "General";
i = i + 1;
}
wb.AutoParse = true;
wb.Save("Demo.xlsx");
If you need any other help, please let us know.
Regards,
Prabhat Sharma.