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.

Format a cell as Text

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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 09:14 AM

Hi Giles,

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

Regards,
Geeta

Giles Billingsley
Replied On September 17, 2009 01:13 PM

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 06:02 AM

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.

%Customers.CompanyName;insert:copystyles

You can refer to our documentation in the link below.
http://help.syncfusion.com/ug/asp.net/xlsio/Documents/templatemarkers.htm

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

Regards,
Geetha

Padma Rajagopal
Replied On April 1, 2013 10:00 AM

Hi

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

Thanks
Padma

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

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.
http://help.syncfusion.com/ug/asp.net/xlsio/default.htm#!Documents/templatemarkers.htm

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.

Thanks,
Manikandan M.


TemplateMarker_484c6e73.zip

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.

;