I have got a very strange problem :
for reading excel I use NPOI nget package and my code is
HttpPostedFileBase file = Request.Files[0];
string fileName = file.FileName;
Stream filestream = file.InputStream;
string fileExtension = System.IO.Path.GetExtension(Request.Files[0].FileName);
if (fileExtension == ".xls" || fileExtension == ".xlsx")
{
HSSFWorkbook hssfwb;
hssfwb= new HSSFWorkbook(filestream);
ISheet sheet = hssfwb.GetSheetAt(0);
for (int row = 1; row <= sheet.LastRowNum; row++)
{
if (sheet.GetRow(row) != null) //null is when the row only contains empty cells
{
Cordinates cord = new Cordinates();
cord.x =sheet.GetRow(row).GetCell(1).StringCellValue;
cord.y = sheet.GetRow(row).GetCell(2).ToString();
cord.h = sheet.GetRow(row).GetCell(3).ToString();
lstCordinatestoReturn.Add(cord);
}
}
SO the strangest thing is that the values in my cells are this 123,233 13,333 (only digits and comma) and no matter that the cell is formatted as text cell - I always get the value with dot
cord.y = sheet.GetRow(row).GetCell(2).ToString(); // theresult will ve 123.2333
and even the first is giving an exception ()
cord.x =sheet.GetRow(row).GetCell(1).StringCellValue; // gives an exception : Cannot get a text value from a numeric cell