How to change the Numberformat to Text from C#

Aug 15, 2013 at 8:55 AM
Hi,

I am using NPOI for Export to .xls file. After Export to .xls when I open all the cell should be in "Text" Numberformat instead of "General". All the cells in the .xls file should take example if I enter 0098 it should stay it shouldn't change to 98.

Please let me know how can I set this in C# using NPOI.

Thanks....
Aug 23, 2013 at 9:47 PM
I dont know if this is what you're looking for, but you can set the Format of cells to Text like this:
//quick example
var cell = sheet.GetRow(3).GetCell(2);
cell.CellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("@");
you can do the same thing at the Row level if you like.

Hope it helps
Marked as answer by tonyqus on 11/17/2013 at 4:23 PM