Search code examples
c#datagridviewexport-to-excel

c# Exported data to Excel not in correct format


Possible Duplicate:
Export Excel : Avoid stripping the leading zeros

I am exporting a datagridview to excel using Interop. The data in the dgv is formatted as expected, and the column in question is of string type within the source datatable. However when exported, an example cell is showing as "39374" in Excel rather than "0039374" which is the value on the datagridview. Is there a way to overcome this?


Solution

  • Just set the appropriate type for the cell itself. check these links,

    How to make Excel with zero before the number in C#

    How to format cells in excel sheet programmatically?