LadyDragon
Programmer
HTML export to excel - losing leading zeros and date format
Hi! I'm hoping someone can help me - I've searched the archives and haven't found this exact issue.
I have an application that I've inherited where a dataset is exporting via an html table to an excel spreadsheet. This process is dropping leading zeros and modifying hyphenated numbers to dates and I don't know how to fix this. I've tried adding '=' in front of the data in the table, but it shows the symbol. Any help you can offer would be fantastic!
I'm using Visual Studio C# and ADO.net:
This is a code snippet that is creating the html output:
Hi! I'm hoping someone can help me - I've searched the archives and haven't found this exact issue.
I have an application that I've inherited where a dataset is exporting via an html table to an excel spreadsheet. This process is dropping leading zeros and modifying hyphenated numbers to dates and I don't know how to fix this. I've tried adding '=' in front of the data in the table, but it shows the symbol. Any help you can offer would be fantastic!
I'm using Visual Studio C# and ADO.net:
This is a code snippet that is creating the html output:
Code:
StringBuilder sb_row = new StringBuilder(20000);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
sb_row.Append("<tr>");
for (int x = 0; x < ccnt; x++)
{
sb_row.Append("<td>" + ds.Tables[0].Rows[i][x].ToString() + "</td>" );
}
sb_row.Append("</tr>");
_sb.Append(sb_row.ToString());
sb_row = new StringBuilder(20000);
}