poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49841] New: LEFT and RIGHT text functions throw a StringIndexOutOfBoundsException when called with a negative operand
Date Sun, 29 Aug 2010 20:04:48 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=49841

           Summary: LEFT and RIGHT text functions throw a
                    StringIndexOutOfBoundsException when called with a
                    negative operand
           Product: POI
           Version: 3.7-dev
          Platform: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: brendan.nolan@gmail.com


LEFT("ANYSTRING", -1)
RIGHT("ANYSTRING", -1)

Either of the functions above should return #VALUE! but return an exception

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String
index out of range: -1
    at java.lang.String.substring(String.java:1937)
    at
org.apache.poi.hssf.record.formula.functions.TextFunction$LeftRight.evaluate(TextFunction.java:183)
    at
org.apache.poi.hssf.record.formula.functions.Var1or2ArgFunction.evaluate(Var1or2ArgFunction.java:36)
    at
org.apache.poi.ss.formula.OperationEvaluatorFactory.evaluate(OperationEvaluatorFactory.java:132)


HSSFWorkbook wbHSSF = new HSSFWorkbook();
HSSFSheet sheetHSSF = wbHSSF.createSheet("LEFTRIGHTTESTSHEET");
FormulaEvaluator createFormulaEvaluator =
wbHSSF.getCreationHelper().createFormulaEvaluator();
HSSFCell createCell =
sheetHSSF.createRow(0).createCell(0,Cell.CELL_TYPE_FORMULA);
createCell.setCellFormula("LEFT(\"ANYSTRING\",-1)");        
createFormulaEvaluator.evaluate(createCell);

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message