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

Created 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?

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>