Adds a test case to TestFormulaParser to parse 3D refs in formulas.
Created attachment 15062 [details] Test case to test parsing 3D refs in formulas.
*** Bug 26483 has been marked as a duplicate of this bug. ***
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); fp.parse(); 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.
(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.
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.
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.
I believe FormulaParser now correctly handles 3d refs, so this patch isn't needed. Please re-open the bug if this is incorrect