ASF Bugzilla – Attachment 33723 Details for
Bug 59271
Regression: Formula parsing fails after update to poi 3.13 if formula contains spaces between closing brackets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
testcase to reproduce the issue
PoiBug59271Test.java (text/x-csrc), 2.57 KB, created by
Kai G
on 2016-04-04 15:06:53 UTC
(
hide
)
Description:
testcase to reproduce the issue
Filename:
MIME Type:
Creator:
Kai G
Created:
2016-04-04 15:06:53 UTC
Size:
2.57 KB
patch
obsolete
>/** > * Dynamic Application Framework > * > * Copyright (c) 2008-2016 Bosch Financial Software GmbH > * > * All rights reserved. > */ > >package com.bosch.fs.daf.excel.functions; > >import static org.junit.Assert.*; > >import java.io.IOException; >import java.io.InputStream; > >import org.apache.poi.hssf.usermodel.HSSFCell; >import org.apache.poi.hssf.util.CellReference; >import org.apache.poi.ss.usermodel.Cell; >import org.apache.poi.ss.usermodel.FormulaEvaluator; >import org.apache.poi.ss.usermodel.Row; >import org.apache.poi.ss.usermodel.Sheet; >import org.apache.poi.ss.usermodel.Workbook; >import org.apache.poi.ss.usermodel.WorkbookFactory; >import org.junit.Test; > >/** > * testcase to reproduce POI bugzilla issue 59271 > * > * @author Kai Grabfelder > */ >public class PoiBug59271Test >{ > @Test > public void testFormulaParsing(){ > Workbook workbook = createWorkbookByClassPathResource("/PoiBug59271Test.xlsx"); > > FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); > > for (int i = 0; i < workbook.getNumberOfSheets(); i++) > { > Sheet xsheet = workbook.getSheetAt(i); > > for (Row row : xsheet) > { > for (Cell cell : row) > { > if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) > { > try > { > evaluator.evaluateFormulaCell( cell ); > } > catch (Exception e) > { > CellReference cellRef = new CellReference( cell.getRowIndex(), cell.getColumnIndex() ); > throw new RuntimeException("error at: " + cellRef.toString() + " "+ e.getMessage(), e ); > > } > } > } > } > } > > Sheet sheet = workbook.getSheet( "my-sheet" ); > Cell cell = sheet.getRow( 1 ).getCell( 4 ); > > assertEquals(5d, cell.getNumericCellValue(), 0d); > } > > > private Workbook createWorkbookByClassPathResource(String resourceName) { > InputStream is = this.getClass().getResourceAsStream( > resourceName); > if (is == null) > throw new IllegalArgumentException("file '" + resourceName > + "' not found"); > try { > return WorkbookFactory.create(is); > } catch (Exception e) { > throw new IllegalArgumentException(e); > } finally { > try { > is.close(); > } catch (IOException e) { > throw new IllegalArgumentException(e); > } > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 59271
: 33723 |
33724