Hello Everyone,
i am generating excel file and its generating as well only issue is some numeric value format is not correct format and because of that i cannot perform any formula. below snap for your refrence.
Code:
cs.dt = (System.Data.DataTable)dataGridView1.DataSource;
System.Data.DataTable dtclone = cs.dt.Clone();
dtclone.Columns[7].DataType = typeof(decimal); //In your case you need to change WaitTime and AssistTime
dtclone.Columns[8].DataType = typeof(decimal);
foreach (DataRow row in cs.dt.Rows)
{
dtclone.ImportRow(row);
}
int b = 0;
string[,] dataa = new string[dtclone.Rows.Count, dtclone.Columns.Count];
foreach (DataRow row in dtclone.Rows)
{
int j = 0;
foreach (DataColumn c in dtclone.Columns)
{
dataa[b, j] = row[c].ToString();
j++;
// Thread.Sleep(100);
}
b++;
}
xlWorkSheet.Range[xlWorkSheet.Cells[4, 1], xlWorkSheet.Cells[dtclone.Rows.Count + 3, dtclone.Columns.Count]].value = dataa;

Feroz KhanPosted Aug 29, 2023, 1:19 PM
Hi Cr Bhargavi,
Thank you for your reply i did the same before also its changing the format with custom but issue still not working in the last column you can see i am using Total its not coming because format not correct and my first screen short there is one option convert to number one i will press then calculating. below new screen for refrence.
Cr BhargaviPosted Aug 29, 2023, 3:32 AM
Leon DPosted Aug 29, 2023, 2:08 AM
You can export data from datatable to excel using Free Spire.XLS.
https://www.e-iceblue.com/Download/download-excel-for-net-free.html
Here is a simple example: