We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How do I get the "formatted" text of a cell value

Hi, Suppose the following code fragment (V3.3.0.0): ws.Range("A1").Number = 10 ws.Range("A1").NumberFormat = "0 ""ms""" I''am not able to retrieve the string "10 ms". In Excel VBA this can be done using the ''Text'' property of a Range object. Thanks, Holger

3 Replies

AD Administrator Syncfusion Team September 29, 2005 06:28 AM UTC

Hi Holger, Here is the Code Snippet: ws.Range("A1").Number = 10 ws.Rage("A1").NumberFormat = "0 \"ms\"" Please, Let me know if you have further questions. Best Regards, Seetha >Hi, > >Suppose the following code fragment (V3.3.0.0): > >ws.Range("A1").Number = 10 >ws.Range("A1").NumberFormat = "0 ""ms""" > >I''am not able to retrieve the string "10 ms". In Excel VBA this can be done using the ''Text'' property of a Range object. > >Thanks, >Holger


HH Holger Haidinger September 29, 2005 09:00 AM UTC

Hi Seetha, thanks for your quick response. My problem is not the ''NumberFormat'' property but the textual output of the ''Text'' property. My code snippet is VB, I assume that "0 \"ms\"" is C# syntax. I will change my code snippet to be more clearer: ws.Range("A1").Number = 10 ws.Rage("A1").NumberFormat = "0.00" Console.WriteLine(ws.Range("A1").Text) I expected that ws.Range("A1").Text would result in "10.00" but it returned "10" (like ws.Range("A1").Value). Excel VBA returns "10.00" instead (the decimal separator is country specific). Do you know a way to retrieve the string "10.00"? Best regards, Holger >Hi Holger, > >Here is the Code Snippet: > >ws.Range("A1").Number = 10 >ws.Rage("A1").NumberFormat = "0 \"ms\"" > >Please, Let me know if you have further questions. > >Best Regards, >Seetha > > >>Hi, >> >>Suppose the following code fragment (V3.3.0.0): >> >>ws.Range("A1").Number = 10 >>ws.Range("A1").NumberFormat = "0 ""ms""" >> >>I''am not able to retrieve the string "10 ms". In Excel VBA this can be done using the ''Text'' property of a Range object. >> >>Thanks, >>Holger


AD Administrator Syncfusion Team October 4, 2005 09:15 AM UTC

Hi Holger, Sorry for delay in getting back to you. I have already logged a feature request regarding this issue, you can track the status of this issue here. http://www.syncfusion.com/support/features/xlsio/Default.aspx?ToDo=view&questId=366 Best Regards, Seetha >Hi Seetha, > >thanks for your quick response. > >My problem is not the ''NumberFormat'' property but the textual output of the ''Text'' property. > >My code snippet is VB, I assume that "0 \"ms\"" is C# syntax. > >I will change my code snippet to be more clearer: > >ws.Range("A1").Number = 10 >ws.Rage("A1").NumberFormat = "0.00" >Console.WriteLine(ws.Range("A1").Text) > >I expected that ws.Range("A1").Text would result in "10.00" but it returned "10" (like ws.Range("A1").Value). Excel VBA returns "10.00" instead (the decimal separator is country specific). > >Do you know a way to retrieve the string "10.00"? > >Best regards, >Holger > >>Hi Holger, >> >>Here is the Code Snippet: >> >>ws.Range("A1").Number = 10 >>ws.Rage("A1").NumberFormat = "0 \"ms\"" >> >>Please, Let me know if you have further questions. >> >>Best Regards, >>Seetha >> >> >>>Hi, >>> >>>Suppose the following code fragment (V3.3.0.0): >>> >>>ws.Range("A1").Number = 10 >>>ws.Range("A1").NumberFormat = "0 ""ms""" >>> >>>I''am not able to retrieve the string "10 ms". In Excel VBA this can be done using the ''Text'' property of a Range object. >>> >>>Thanks, >>>Holger

Loader.
Live Chat Icon For mobile
Up arrow icon