Bug 34944 - [PATCH] Add test case to TestFormulaParser for 3D refs
Summary: [PATCH] Add test case to TestFormulaParser for 3D refs
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
: 26483 (view as bug list)
Depends on:
Blocks: 21923
  Show dependency tree
Reported: 2005-05-17 23:02 UTC by Eric Ladner
Modified: 2008-07-10 16:04 UTC (History)
0 users

Test case to test parsing 3D refs in formulas. (2.69 KB, patch)
2005-05-17 23:03 UTC, Eric Ladner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Ladner 2005-05-17 23:02:50 UTC
Adds a test case to TestFormulaParser to parse 3D refs in formulas.
Comment 1 Eric Ladner 2005-05-17 23:03:35 UTC
Created attachment 15062 [details]
Test case to test parsing 3D refs in formulas.
Comment 2 Avik Sengupta 2005-05-19 15:33:45 UTC
*** Bug 26483 has been marked as a duplicate of this bug. ***
Comment 3 Avik Sengupta 2005-05-19 15:41:06 UTC
OK, from the bug, it looks to me that ...

this works
cell.setCellFormula("A!A1+A!B1"); //cell is in sheet B

but this doesnt
FormulaParser fp = new FormulaParser("A!A1+A!B1", null);

but should it matter? HSSFCell should do the right thing internally. Why would
you want to direcly access fp from outside?

But Eric, maybe I dont understand your use case. In particular, is the above all
you are trying to achieve in bug 21923?  I havent answered your question there
since I dont think I have understood this yet. 

Comment 4 Eric Ladner 2005-05-20 06:03:39 UTC
(In reply to comment #3)
> Why would you want to direcly access fp from outside?

I've got a spread sheet that over time has gotten so complex that nobody really
understands how it works any more.  It's six sheets and each sheet has hundreds
of columns of data, and each sheet combines data from the previous sheet in
linear ways to form aggregated and scaled data.  

The end result with the formula parser was to take the a formula on page one and
unwind the calculations (parse the formula, go grab the cells it references, if
they are formulas, parse them, grab the cells they reference, etc.) until I get
a list of the source data (and the COMPLETE calculation as one forumla) that's
involved in each calculation on the first page.

That was the problem I was trying to solve.

Seemed logical enough at the time.
Comment 5 Avik Sengupta 2005-05-20 13:33:28 UTC
Ok, I get your usecase, and POI as it stands does not support this. And I am not
sure if I like any of the suggested solutions. 

I'd thought of something like this a long time ago, and my preferred option was
to actually build a high level api for the formulas, so a method in HSSFCell
that would return the parsed formula, as an array of, for eg, CellReference
objects and HSSFFormulaOp(sic) objects. You could then traverse the tree. 

Actually, with Amol's work, what I call the HSSFFormulaOp, could very well be
his Eval objects. It could all be tied up nicely. 
Comment 6 Eric Ladner 2005-05-20 13:42:03 UTC
Works for me.  The only thing I really need is access to the Ptg array that the
formula parser returns, manipulate it, and send it to
FormulaParser.toFormulaString().  Doing that through the cell (along with stuff
like getCellFormula()) makes sense to me.  Not sure how you'd implement the ptg
-> string part though but cell -> pgts seems easy.
Comment 7 Nick Burch 2008-07-10 16:04:16 UTC
I believe FormulaParser now correctly handles 3d refs, so this patch isn't needed. Please re-open the bug if this is incorrect