This project has moved. For the latest updates, please go here.

Force ColumnFormat to "TEXT"

Nov 29, 2010 at 4:29 PM

Can I set the numberformat to TEXT? 

 

I want to force a number of columns to always show text. I cannot find what value I should provide to get this to work...

 

Jesse

Editor
Nov 29, 2010 at 4:35 PM

Do you want to show a number as a text ?

Maybe you can try to use formula...something like that:

 

                ws.Cells[1, 1].Formula = "TEXT(\"" + 2+ "\",\"#\")";

Nov 29, 2010 at 4:39 PM

Turns out setting the Formatstring to "@" does the trick :D

Apr 4, 2012 at 5:17 PM

Hi Jesse, please could you tell us what object the property Formatstring belogs to? Or do you mean ws.Column(i).Style.Numberformat.Format = "@";

Thanks, Carlos.

Apr 4, 2012 at 5:41 PM

Have to dig a bit.. I'm not on this project any more, so I'll have to do this from memory...But I think you're right. Setting that field should do it.

May 30, 2012 at 7:15 PM

I found the "@" format in the

myPkg.Workbook.Styles.NumberFormats

collection. It doesn't have a specific name for referencing (that I can see), but Excel 2010 interprets the format as Text.