Excel Range Format: Number is automatically formatted when Range::Value2 is set

Posted by A9S6 on Stack Overflow See other posts from Stack Overflow or by A9S6
Published on 2009-09-11T11:50:41Z Indexed on 2010/04/05 5:13 UTC
Read the original article Hit count: 468

Filed under:
|
|

I have an Excel addin written in C# that imports a text file into Excel worksheet. Some of the fields in the file are text and some oare numbers.

Problem Steps:

  1. Change the System's Regional Settings to Dutch (Belgium)
  2. Open Excel and import the file into Excel. Records contain values such as 78,1118 which gets converted to 781.118. Note that in Dutch(Belgium), COMMA is the decimal character and DOT is the thousand character.

I do not require the number to be formatted automatically but just want to display whatver I get from the file (78,1118). If I set the cell's NumberFormat to "@" i.e. Text, then it displays an error (SmartTag) saying "Number stored as Text". I know I can change the settings by going to the "Options" box but I dont want to change any user options in Excel for this. I have tried setting the cell's Value2 with an "'" (apostrophe) but the same error is displayed. If I set the cell's format to something else after the value is set then the actual value changes and I loose the decimal.

Is there a way in Excel to just display the value and NOT display the "Number Stored as Text" error in cell?

© Stack Overflow or respective owner

Related posts about excel

Related posts about range