views:

666

answers:

1

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?

A: 

in c#

ExcelApplication.ErrorCheckingOptions.NumberAsText=false

Archana