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

Treat Number as Text

Hi,

I am trying to change a number in a cell to be treated as text.

The usual trick was to add an apostrophe infront of the number.

Example Cell.Text = 5 changed to Cell.Text = '5

If I do this in excel it does not show the apostrophe but treats the 5 as text instead of a number.

In XlsIO I tried Cell.Value2 = "'" + Cell.Text; but that gave me two apostrophes.

Any help would be appreciated.

2 Replies

CB Chris Bishop July 15, 2013 08:18 PM UTC

I got what I wanted.  Cell.Value2 = "'" + CellValue2.

But what I was trying to achieve still failed.  I wanted the little green arrow to go away and in other sheets I have it was accomplished by referencing the cell that has the '5.  The original cell is flagged but any referencing cells are not.

Basically, you can ignore this post.


RA Rajesh A Syncfusion Team July 19, 2013 06:17 AM UTC

Hi Chris,

  Thank you for using the Syncfusion products.

We have analyzed your code snippet and we could suspect it’s a usage issue. We have updated the possible code snippets for “converting the Number to as text” and also we have attached the sample for your reference. Please make use of this and let us know if this helps you.

Code Snippet:

sheet.IsStringsPreserved = true;

sheet["A1"].Value2 = "9";

 Or

sheet["A1"].Value2 = "'9";

sheet["A1"].CellStyle.IsFirstSymbolApostrophe = false;

Sample link: Sample - Number As Text.zip

Please let us know if you have any clarification.

Thanks,

Rajesh.A

 


Loader.
Live Chat Icon For mobile
Up arrow icon