Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

Commented Unassigned: Incorrect value of calculation in XSSFWorkbook [13108]

$
0
0
In the next example I try to calculate formula "B1/A1":
```
var workbook = new XSSFWorkbook();

var sheet = workbook.CreateSheet();

var row = sheet.CreateRow(0);

var cell = row.CreateCell(0);
cell.SetCellType(CellType.Numeric);
cell.SetCellValue(150.0);

cell = row.CreateCell(1);
cell.SetCellType(CellType.Numeric);
cell.SetCellValue(25.0);

cell = row.CreateCell(2);
cell.SetCellType(CellType.Formula);
cell.SetCellFormula("B1/A1");

workbook.GetCreationHelper().CreateFormulaEvaluator().EvaluateAll();

```
Result in the C1 cell should be 0.16. However, the C1 cell returns 166666666666667.0. When I replace workbook creation to the:
```
var workbook = new HSSFWorkbook();
```
it works fine. But this implementation of IWorkbook has limitation in row count (max 65K). How can I fix this bug in XSSFWorkbook?
Comments: ** Comment from web user: Herbiee **

This issue seems to be fixed in NPOI 2.1.1. If I run the code above I get the "NumericCellValue" 0.166666666666667 for XSSFWorkbook.


Viewing all articles
Browse latest Browse all 1621

Trending Articles