You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Jeffrey A Kenward <ke...@dteenergy.com> on 2008/10/08 22:00:49 UTC

Copying a formula

I'm using the 3.5 beta to read a 2007 excel workbook.

In my sheet, I created a cell (F2) that had a simple formula : =C2*D2

In my code, it realizes this is a formula and evaluates properly.

In excel, I dragged the formula down so that F3:F380 had the same 
effective formula as F2 (C3*D3, etc).

When F3 is evaluated, it works ok, but when F4 is evaluated, it bombs with 
the stack trace below.

If I enter the formula manually it works ok, but when I drag the formula 
down, it keeps doing that.  Is this functionality supported?  Do you have 
to evaluate the cell differently?

-Jeff

org.apache.poi.hssf.model.FormulaParser$FormulaParseException: Parse error 
near char 0 '
        at 
org.apache.poi.hssf.model.FormulaParser.expected(FormulaParser.java:142)
        at 
org.apache.poi.hssf.model.FormulaParser.parseNumber(FormulaParser.java:570)
        at 
org.apache.poi.hssf.model.FormulaParser.parseSimpleFactor(FormulaParser.java:537)
        at 
org.apache.poi.hssf.model.FormulaParser.percentFactor(FormulaParser.java:499)
        at 
org.apache.poi.hssf.model.FormulaParser.powerFactor(FormulaParser.java:486)
        at 
org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:694)
        at 
org.apache.poi.hssf.model.FormulaParser.additiveExpression(FormulaParser.java:775)
        at 
org.apache.poi.hssf.model.FormulaParser.concatExpression(FormulaParser.java:759)
        at 
org.apache.poi.hssf.model.FormulaParser.comparisonExpression(FormulaParser.java:716)
        at 
org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:817)
        at 
org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:116)
        at 
org.apache.poi.ss.usermodel.FormulaEvaluator.evaluateCell(FormulaEvaluator.java:333)
        at 
org.apache.poi.ss.usermodel.FormulaEvaluator.internalEvaluate(FormulaEvaluator.java:326)
        at 
org.apache.poi.ss.usermodel.FormulaEvaluator.evaluate(FormulaEvaluator.java:133)
        at 
com.dteco.pmp.ExcelSheetReader.getStringValue(ExcelSheetReader.java:235)
        at 
com.dteco.pmp.ExcelSheetReader.readCells(ExcelSheetReader.java:202)
        at 
com.dteco.pmp.ExcelSheetReader.collectData(ExcelSheetReader.java:191)
        at 
com.dteco.pmp.ExcelSheetReader.getTabularData(ExcelSheetReader.java:116)
        at 
com.dteco.pmp.ZReportExtractor.loadEmpStocksMap(ZReportExtractor.java:229)
        at 
com.dteco.pmp.ZReportExtractor.reportExtract(ZReportExtractor.java:157)
        at 
com.dteco.pmp.SuccessFactorsRunner.main(SuccessFactorsRunner.java:27)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

*** PROPRIETARY, CONFIDENTIAL OR PRIVILEGED COMMUNICATION ***
This communication may contain proprietary, privileged or confidential 
information protected by law. It is solely for the use of the intended 
recipient named above. Any review, dissemination, distribution, 
forwarding, or copying of this communication by someone other than the 
intended recipient, or the employee responsible for delivering this 
communication to the intended recipient, is prohibited. If you have 
received this communication in error, please immediately notify the sender 
via email, then destroy the original message.

Re: Copying a formula

Posted by Jeffrey A Kenward <ke...@dteenergy.com>.
Nevermind I guess.  I think I was making it too complicated on myself by 
using the evaluator.

It works just fine if I do the way the XSSFExcelExtractor is doing it just 
by using the XSSFCell getRawValue method.

-Jeff

*** PROPRIETARY, CONFIDENTIAL OR PRIVILEGED COMMUNICATION ***
This communication may contain proprietary, privileged or confidential 
information protected by law. It is solely for the use of the intended 
recipient named above. Any review, dissemination, distribution, 
forwarding, or copying of this communication by someone other than the 
intended recipient, or the employee responsible for delivering this 
communication to the intended recipient, is prohibited. If you have 
received this communication in error, please immediately notify the sender 
via email, then destroy the original message.



Jeffrey A Kenward <ke...@dteenergy.com> 
10/08/2008 04:02 PM
Please respond to
"POI Developers List" <de...@poi.apache.org>


To
dev@poi.apache.org
cc

Subject
Copying a formula






I'm using the 3.5 beta to read a 2007 excel workbook.

In my sheet, I created a cell (F2) that had a simple formula : =C2*D2

In my code, it realizes this is a formula and evaluates properly.

In excel, I dragged the formula down so that F3:F380 had the same 
effective formula as F2 (C3*D3, etc).

When F3 is evaluated, it works ok, but when F4 is evaluated, it bombs with 

the stack trace below.

If I enter the formula manually it works ok, but when I drag the formula 
down, it keeps doing that.  Is this functionality supported?  Do you have 
to evaluate the cell differently?

-Jeff

org.apache.poi.hssf.model.FormulaParser$FormulaParseException: Parse error 

near char 0 '
        at 
org.apache.poi.hssf.model.FormulaParser.expected(FormulaParser.java:142)
        at 
org.apache.poi.hssf.model.FormulaParser.parseNumber(FormulaParser.java:570)
        at 
org.apache.poi.hssf.model.FormulaParser.parseSimpleFactor(FormulaParser.java:537)
        at 
org.apache.poi.hssf.model.FormulaParser.percentFactor(FormulaParser.java:499)
        at 
org.apache.poi.hssf.model.FormulaParser.powerFactor(FormulaParser.java:486)
        at 
org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:694)
        at 
org.apache.poi.hssf.model.FormulaParser.additiveExpression(FormulaParser.java:775)
        at 
org.apache.poi.hssf.model.FormulaParser.concatExpression(FormulaParser.java:759)
        at 
org.apache.poi.hssf.model.FormulaParser.comparisonExpression(FormulaParser.java:716)
        at 
org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:817)
        at 
org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:116)
        at 
org.apache.poi.ss.usermodel.FormulaEvaluator.evaluateCell(FormulaEvaluator.java:333)
        at 
org.apache.poi.ss.usermodel.FormulaEvaluator.internalEvaluate(FormulaEvaluator.java:326)
        at 
org.apache.poi.ss.usermodel.FormulaEvaluator.evaluate(FormulaEvaluator.java:133)
        at 
com.dteco.pmp.ExcelSheetReader.getStringValue(ExcelSheetReader.java:235)
        at 
com.dteco.pmp.ExcelSheetReader.readCells(ExcelSheetReader.java:202)
        at 
com.dteco.pmp.ExcelSheetReader.collectData(ExcelSheetReader.java:191)
        at 
com.dteco.pmp.ExcelSheetReader.getTabularData(ExcelSheetReader.java:116)
        at 
com.dteco.pmp.ZReportExtractor.loadEmpStocksMap(ZReportExtractor.java:229)
        at 
com.dteco.pmp.ZReportExtractor.reportExtract(ZReportExtractor.java:157)
        at 
com.dteco.pmp.SuccessFactorsRunner.main(SuccessFactorsRunner.java:27)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

*** PROPRIETARY, CONFIDENTIAL OR PRIVILEGED COMMUNICATION ***
This communication may contain proprietary, privileged or confidential 
information protected by law. It is solely for the use of the intended 
recipient named above. Any review, dissemination, distribution, 
forwarding, or copying of this communication by someone other than the 
intended recipient, or the employee responsible for delivering this 
communication to the intended recipient, is prohibited. If you have 
received this communication in error, please immediately notify the sender 

via email, then destroy the original message.