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.
Unfortunately, activation email could not send to your email. Please try again.

Treat Number as Text

Thread ID:

Created:

Updated:

Platform:

Replies:

109998 Jul 15,2013 04:10 PM Jul 19,2013 02:17 AM Windows Forms 2
loading
Tags: XlsIO
Chris Bishop
Asked On July 15, 2013 04:10 PM

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.

Chris Bishop
Replied On July 15, 2013 04:18 PM

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.

Rajesh A [Syncfusion]
Replied On July 19, 2013 02:17 AM

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

 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;