ASF Bugzilla – Attachment 36497 Details for
Bug 61841
Unnecessary long computation when evaluating VLOOKUP on all column reference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
PoiFormulaChecker class demonstrating problem
PoiFormulaChecker.java (text/x-java), 2.24 KB, created by
Travis Burtrum
on 2019-03-25 18:45:48 UTC
(
hide
)
Description:
PoiFormulaChecker class demonstrating problem
Filename:
MIME Type:
Creator:
Travis Burtrum
Created:
2019-03-25 18:45:48 UTC
Size:
2.24 KB
patch
obsolete
> >import org.apache.poi.ss.usermodel.*; >import org.apache.poi.xssf.usermodel.XSSFWorkbook; > >public class PoiFormulaChecker { > public static void main(String[] args) throws Throwable { > > final org.apache.poi.xssf.usermodel.XSSFWorkbook wb = new XSSFWorkbook(); wb.setCellFormulaValidation(false); > > //final Workbook wb = new org.apache.poi.hssf.usermodel.GenericSSEvaluationWorkbook(); > > //final Workbook wb = new org.apache.poi.hssf.usermodel.HSSFWorkbook(); > > final FormulaEvaluator formulaEval = wb.getCreationHelper().createFormulaEvaluator(); > final Sheet sheet = wb.createSheet(); > int rowNum = -1, cellNum; > Row row; > Cell formulaCell; > CellValue evaluatedCell = null; > > row = sheet.createRow(++rowNum); > cellNum = -1; > row.createCell(++cellNum).setCellValue("Product1"); > row.createCell(++cellNum).setCellValue(10.67); > row.createCell(++cellNum).setCellValue(8); > > double price = 19.57; > int quantity = 3; > > final long start = System.currentTimeMillis(); > > final int maxRow = 4; > > for(int x = 2; x < maxRow; ++x) { > row = sheet.createRow(++rowNum); > cellNum = -1; > row.createCell(++cellNum).setCellValue("Product" + x); > price += 10; > quantity += 1; > row.createCell(++cellNum).setCellValue(price); > row.createCell(++cellNum).setCellValue(quantity); > > formulaCell = row.createCell(++cellNum); > formulaCell.setCellFormula("VLOOKUP(\"Product" + x + "\",$A:$C,2,0)"); > //formulaCell.setCellFormula("VLOOKUP(\"Product" + x + "\",A" + x + ":C" + x + ",2,0)"); > //System.out.println("formulaCell: " + formulaCell); > evaluatedCell = formulaEval.evaluate(formulaCell); > //System.out.println("evaluatedCell: " + evaluatedCell); > } > > System.out.println("evaluatedCell: " + evaluatedCell); > > final long elapsed = System.currentTimeMillis() - start; > System.out.printf("impl: %s, maxRow: %d, elapsed: %dms, %ds, %dmin%n", wb.getClass().getSimpleName(), maxRow, elapsed, > elapsed / 1000, elapsed / 1000 / 60); > } >}
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 61841
:
35573
| 36497