poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Danny Mui <da...@muibros.com>
Subject Re: Formula: "40000/2" gives exception
Date Thu, 27 Jan 2005 17:16:41 GMT
ok caught, haven't been keeping up with bugzilla :(

Avik Sengupta wrote:
> http://issues.apache.org/bugzilla/show_bug.cgi?id=33160
> 
> On Wed, 2005-01-26 at 16:42 -0500, Danny Mui wrote:
> 
>>oof that looks awful.  please post the bug up for someone to look at.
>>
>>Amol Deshmukh wrote:
>>
>>>Hi,
>>>
>>>following code:
>>>
>>>cell.setCellFormula("40000/2");
>>>
>>>throws exception:
>>>
>>>java.lang.NumberFormatException: Value out of range. Value:"40000" Radix:10
>>>	at java.lang.Short.parseShort(Unknown Source)
>>>	at java.lang.Short.parseShort(Unknown Source)
>>>	at org.apache.poi.hssf.record.formula.IntPtg.<init>(IntPtg.java:58)
>>>	at
>>>org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:486)
>>>	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)
>>>
>>>Apparently it is a bug because if i enter the same in excel as: =40000/2 it
>>>works fine and displays 20000. (The value is retained on closing the
>>>reopening the file in excel.)
>>>
>>>Here is a test program:
>>>Test program:
>>>
>>>import org.apache.poi.hssf.usermodel.HSSFCell;
>>>import org.apache.poi.hssf.usermodel.HSSFRow;
>>>import org.apache.poi.hssf.usermodel.HSSFSheet;
>>>import org.apache.poi.hssf.usermodel.HSSFWorkbook;
>>>public class TestPOIWithNotes {
>>>
>>>    public static void main(String[] args) throws Exception {
>>>        HSSFWorkbook workbook = new HSSFWorkbook();
>>>        HSSFSheet sheet = workbook.createSheet();
>>>        HSSFRow row = sheet.createRow(0);
>>>        HSSFCell cell = row.createCell((short) 0);
>>>        cell.setCellFormula("40000/2");
>>>        // other code here but above line throws exception
>>>    }
>>>}
>>>
>>>
>>>I was going to enter this into bug database, but wanted to be sure before I
>>>did that...
>>>
>>>~ amol
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>>>Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
>>>The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>>Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
>>The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Mime
View raw message