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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Format a cell as Text

Thread ID:





89942 Sep 10,2009 06:01 PM UTC Apr 5,2013 04:40 AM UTC ASP.NET Web Forms (Classic) 5
Tags: XlsIO
Giles Billingsley
Asked On September 10, 2009 06:01 PM UTC

How can I ensure a string entered into a cell is treated as text? Is there an opposite to using NumberFormat where I can specify a range can be formatted as Text?

I'm successfully populating spreadsheet with data from a database. The number and type of columns vary so I've created a simple xls file to use as a template which I then fill using markers.

Occasionally an field might contain a string such as '5E1' or '5PM', which excel tries to interpret as a number or a date.

In Excel the only way to overcome the problem is to format a cell as Text before typing in the string, and I've tried formatting all the cells in my template to Text, but after importing the data, it a cell containing '5E1' will have been reformatted as a number, so I think I need to actively do something using XlsIO to force it to treat something as text.

Any ideas would be appreciated

Geetha M [Syncfusion]
Replied On September 16, 2009 01:14 PM UTC

Hi Giles,

I was able to see the problem. I am currently working on this and will get back to you by tomorrow.


Giles Billingsley
Replied On September 17, 2009 05:13 PM UTC

Thanks. I've now got around this issue by looping through the rows, after I've filled the sheet with data, and setting the '.Text' of the offending cell to the value I want treated as text, and then I can also set '.IgnoreErrorOptions = ExcelIgnoreError.All' to stop the number-as-text green arrow appearing on the cell. It works fine, but it would be nice for all that to happen as part of ApplyMarkers.

Geetha M [Syncfusion]
Replied On September 18, 2009 10:02 AM UTC

Hi Giles,

Thank you for the detials.

You may also set the number format for the variable cell as Text and use insert:copystyles as marker argument. This will copy the styles from the previous row while applying marker.


You can refer to our documentation in the link below.

Please try this and let me know if you have any questions.


Padma Rajagopal
Replied On April 1, 2013 02:00 PM UTC


This solution of setting number format of the cell to text, still wouldn't work. Is there a way of applying "text" format using ApplyMarkers method? I don't want to loop through each cell & setting its "text" property value.

Also, this link doesn't work anymore  - http://help.syncfusion.com/ug_73/xlsio/TemplateMarkers.html


Manikandan M [Syncfusion]
Replied On April 5, 2013 04:40 AM UTC

Hi Padma,

Thank you very much for your patience.

We are afraid that we are not able to reproduce the issue "Setting the number format to 'text' format and then applying the template marker does work" from side. We have created the simplified sample to apply the number format to 'text' and applying the template marker with 'copystyles' option. We have shared the sample below. Please make use of this and let us know if this helps you.

Also we have shared the updated online help link of template marker below.

if you still reproduce the issue, please modify the above sample to reproduce the issue and revert back us with the same. it would help us to investigate further on this.

Please let us know if you need any clarifications.

Manikandan M.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon