The code - cell.setCellFormula("right(\'hello\', 5)"); [The formula is, of course, incorrect - it should be " and not '; but the poi code, seeing the ', checked if it was a sheet name in a cell reference and gave an error] gives an error - java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at org.apache.poi.hssf.util.CellReference.<init>(CellReference.java:44) at org.apache.poi.hssf.record.formula.ReferencePtg.<init> (ReferencePtg.java:50) at org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:291) at org.apache.poi.hssf.model.FormulaParser.Factor (FormulaParser.java:474) at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:548) at org.apache.poi.hssf.model.FormulaParser.Expression (FormulaParser.java:596) at org.apache.poi.hssf.model.FormulaParser.Arguments (FormulaParser.java:443) at org.apache.poi.hssf.model.FormulaParser.function (FormulaParser.java:315) at org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:265) at org.apache.poi.hssf.model.FormulaParser.Factor (FormulaParser.java:474) at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:548) at org.apache.poi.hssf.model.FormulaParser.Expression (FormulaParser.java:596) at org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:700) at org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula (HSSFCell.java:678) at emr.test.Test.setSecondRow(Test.java:85) at emr.test.Test.main(Test.java:116) Exception in thread "main"
Will now throw IllegalArgumentException. Fixed in SVN. Jason