Hi,
I am getting a runtime exception 'Input string was not in a correct format' when I am trying to read a cell of type 'Number' and when its blank in the excel sheet.
Below is the code while writing the excel. Here I m explicitly inserting __blank__ when the value is __zero__ and setting the datatype as XLCellValues.Number.
```
var locationValue = GetLocValue(1);
var cellindex = "A1";
worksheetProposal.Cell(cellindex)
.SetValue(locationValue == 0 ? string.Empty : locationValue.ToString())
.SetDataType(XLCellValues.Number);
```
Below is the code while reading the generated excel. Its throwing an exception when m tring the read the same cell "A1" when its blank.
```
var LocationId = worksheet.Cell("A1").Value; // Runtime exception 'Input string was not in a correct format' when its blank.
```
Does anyone came across such scenario? Any solution for this?
Comments: That's because you're setting the data type of number to a cell that contains a string. You probably meant to set the cell format/style as number. For that you can use the number format id of 2 (Excel's default). See https://closedxml.codeplex.com/wikipage?title=NumberFormatId%20Lookup%20Table
I am getting a runtime exception 'Input string was not in a correct format' when I am trying to read a cell of type 'Number' and when its blank in the excel sheet.
Below is the code while writing the excel. Here I m explicitly inserting __blank__ when the value is __zero__ and setting the datatype as XLCellValues.Number.
```
var locationValue = GetLocValue(1);
var cellindex = "A1";
worksheetProposal.Cell(cellindex)
.SetValue(locationValue == 0 ? string.Empty : locationValue.ToString())
.SetDataType(XLCellValues.Number);
```
Below is the code while reading the generated excel. Its throwing an exception when m tring the read the same cell "A1" when its blank.
```
var LocationId = worksheet.Cell("A1").Value; // Runtime exception 'Input string was not in a correct format' when its blank.
```
Does anyone came across such scenario? Any solution for this?
Comments: That's because you're setting the data type of number to a cell that contains a string. You probably meant to set the cell format/style as number. For that you can use the number format id of 2 (Excel's default). See https://closedxml.codeplex.com/wikipage?title=NumberFormatId%20Lookup%20Table