If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > issue with "Numbers Stored as Text"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-09-04, 19:30
cedralpass cedralpass is offline
Registered User
 
Join Date: Jan 2004
Posts: 4
Question issue with "Numbers Stored as Text"

I am running against a little issue. I have an excel spreadsheet, that I need to be able to read in C#. No problem there. The issue is that the system creating the spreadsheet uses a particular trick to format an number, so that the leading "0" is intact and displays. For example, the system writes a '02.7 so that 2.7 displays.

When I travers the Range and read the value of the cell in c# or even the VBA Macro editor built into Excel, I get the numerical 02.7. I do not get the text '02.7. I need the full text. Does anyone know how excel stores the original data in the cell and how to get it back. I noticed that there is a little green triangle in the top, left corner of the cell. This has an error called "Number Stored as Text" I have tried looking at the range's error object with no luck.

Here is how I am getting the value in c#
Excel.Range rngCurrent =
exlRange.get_Range("B3", System.Reflection.Missing.Value);

rngCurrent.Value2.ToString();

Thanks!!
Reply With Quote
  #2 (permalink)  
Old 04-15-04, 08:52
actuary actuary is offline
Registered User
 
Join Date: Mar 2004
Location: Fort Worth, Texas, USA
Posts: 68
I can't reproduce completely without C#, but this simple case works in VBA:

In sheet1, cell A1: Format the cell as text (Format, Cells, Text). Type in 02.7

Sub test()
With ThisWorkbook.Sheets("Sheet1").Cells(1, 1)
Debug.Print .Value
End With
End Sub
Reply With Quote
  #3 (permalink)  
Old 04-15-04, 12:20
cedralpass cedralpass is offline
Registered User
 
Join Date: Jan 2004
Posts: 4
Thanks! However, The problem is that the string '02.7 is entered into the cell. When I use the following code you have provided it still returns 02.7. I need to be able to get the whole string including the apostrophe.

Thanks again!

Quote:
Originally posted by actuary
I can't reproduce completely without C#, but this simple case works in VBA:

In sheet1, cell A1: Format the cell as text (Format, Cells, Text). Type in 02.7

Sub test()
With ThisWorkbook.Sheets("Sheet1").Cells(1, 1)
Debug.Print .Value
End With
End Sub
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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