This project is read-only.

Get Cell Formatting

Oct 28, 2011 at 4:33 PM
Edited Oct 28, 2011 at 6:40 PM

I am new to NPOI and am having an issue getting the proper cell formatting when reading in from a worksheet.  The information I am reading in will only be accurate when the cell format is set to "text" instead of the default of "general."  I need to verify that when a file is imported, the cells are formatted to "text" and if not, an error message is generated.  I am using:

string strColTest = sheet.GetRow(0).GetCell(0).CellType.ToString();

and get a return of "STRING" whether the cell is formatted as general or text.  Is there another way that I am missing?

I am also attempting this using: 

strColTest = sheet.GetRow(0).GetCell(0).CellStyle.ToString(); 

This is returning "NPOI.HSSF.UserModel.HSSFCellStyle"

Any help would be greatly appreciated, thanks!