Hi,
I am using the Cells.InsertDataTable functionality wherein I import a dataTable from a query to a particular worksheet in the Excel file.
![Image]()
As you can see, columns P and Q contain integers and thus automatically recognized and has formula that is why they are in the right side of the cell. but columns R to W are time values and therefore are recognized only as strings that is why they are on the left side.
In my previous implementation, I use the QueryTables interface of Excel interop wherein I transfer a CSV file coming from a dataTable to Excel that is why all the cells have formula and are on the right side when I opened the Excel file.
But yeah, Excel Automation using the Interop is not recommended for server-side deployment.
Are there any similar ways to do the same using ClosedXML?
Any ideas are appreciated.
Thanks!
I am using the Cells.InsertDataTable functionality wherein I import a dataTable from a query to a particular worksheet in the Excel file.
public void ClosedXml(DataTable dt, string usertemplate, string exceltab)
{
var workbook = new XLWorkbook(usertemplate);
var worksheet = workbook.Worksheet(exceltab);
worksheet.Cell("A2").InsertData(dt.AsEnumerable());
workbook.Save();
}
But when I opened the Excel file, the results were not the ones I expected.
As you can see, columns P and Q contain integers and thus automatically recognized and has formula that is why they are in the right side of the cell. but columns R to W are time values and therefore are recognized only as strings that is why they are on the left side.
In my previous implementation, I use the QueryTables interface of Excel interop wherein I transfer a CSV file coming from a dataTable to Excel that is why all the cells have formula and are on the right side when I opened the Excel file.
But yeah, Excel Automation using the Interop is not recommended for server-side deployment.
Are there any similar ways to do the same using ClosedXML?
Any ideas are appreciated.
Thanks!