Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default setting cell contents to text using C#

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default setting cell contents to text using C#

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting rows to autofit wrapping text in a cell John Excel Discussion (Misc queries) 1 January 8th 10 12:22 AM
Setting up a cell that contains text and a data reference? Melanie Excel Worksheet Functions 5 February 28th 07 03:41 PM
Display contents of cell in another cell as part of text string? [email protected] New Users to Excel 3 July 8th 06 07:44 PM
Setting text as a background in cell Brian Excel Worksheet Functions 1 December 9th 04 08:12 PM
Setting list box contents P Dudesek Excel Programming 5 November 28th 03 04:45 PM


All times are GMT +1. The time now is 11:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"