setting cell contents to text using C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When dumping data into an excel
sheet programmatically using C#,
I run into the problem of
Excel auto-formatting the cells
based on the contents of the cells.
For example, when placing a string
of numbers such as '0000234', the
cell will turn it into the number 234.
We need to keep the preceding 0's for
data integrity. Is there a way in C#
to programmatically specify the cell format (such
text, number, etc.) so that Excel will
not automatically decide the cell's data format?

Thanks.
 
When dumping data into an excel
sheet programmatically using C#,
I run into the problem of
Excel auto-formatting the cells
based on the contents of the cells.

I guess the question is how you are "dumping" the data.
If you can set the NumberFormat of the cell to "@" (for text) before
setting its Value property then the leading zeros should remain.

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup
 
Back
Top