poi/src/java/org/apache/poi/ss/formula/FormulaParser.java

1535 lines
40 KiB
Java
Raw Normal View History

/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss.formula;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
Merged revisions 693591,693639,693658,693939,693941,693947,693990,694050,694065,694153,694534,694615,694619-694620,694631,694643,694877,694881 via svnmerge from https://svn.apache.org/repos/asf/poi/trunk ........ r693591 | josh | 2008-09-09 21:25:16 +0100 (Tue, 09 Sep 2008) | 1 line Added support for parsing array constants in formulas. (Helping investigation for bug 45752) ........ r693639 | josh | 2008-09-09 23:26:28 +0100 (Tue, 09 Sep 2008) | 1 line removed debug code accidentally submitted with r693591 ........ r693658 | josh | 2008-09-10 00:46:46 +0100 (Wed, 10 Sep 2008) | 2 lines Fixed special cases of INDEX function (single columns / single rows, and errors) ........ r693939 | josh | 2008-09-10 20:23:43 +0100 (Wed, 10 Sep 2008) | 1 line Fixing error value handling for numeric functions. Refactored hierarchy. ........ r693941 | josh | 2008-09-10 20:27:24 +0100 (Wed, 10 Sep 2008) | 1 line (Should have been submitted with 693939) Fixing error value handling for numeric functions. Refactored hierarchy. ........ r693947 | josh | 2008-09-10 20:33:58 +0100 (Wed, 10 Sep 2008) | 1 line (Should have been submitted with 693939) Fixing error value handling for numeric functions. Refactored hierarchy. ........ r693990 | josh | 2008-09-10 22:21:28 +0100 (Wed, 10 Sep 2008) | 1 line Refactored hierarchy of MultiOperandNumericFunction. Fixed error value handling. Enabled error value check in TestFormulasFromSpreadsheet ........ r694050 | josh | 2008-09-10 23:43:30 +0100 (Wed, 10 Sep 2008) | 1 line Refactored finance functions. ........ r694065 | josh | 2008-09-11 00:37:22 +0100 (Thu, 11 Sep 2008) | 1 line fixed special cases of MODE function ........ r694153 | josh | 2008-09-11 08:16:20 +0100 (Thu, 11 Sep 2008) | 1 line Refactoring MultiOperandNumericFunction - removed Ref2DEval. ........ r694534 | josh | 2008-09-12 00:18:50 +0100 (Fri, 12 Sep 2008) | 1 line Fix for bug 45639 - cleaned up index logic inside ColumnInfoRecordsAggregate ........ r694615 | josh | 2008-09-12 07:14:07 +0100 (Fri, 12 Sep 2008) | 1 line small tweak to unit test which was silently creating UnknownPtgs ........ r694619 | josh | 2008-09-12 07:58:52 +0100 (Fri, 12 Sep 2008) | 1 line Removed trailing comma from output of HexDump.toHex() ........ r694620 | josh | 2008-09-12 08:03:00 +0100 (Fri, 12 Sep 2008) | 1 line clarification of ArrayPtg size increment ........ r694631 | josh | 2008-09-12 08:43:20 +0100 (Fri, 12 Sep 2008) | 1 line Extended support for cached results of formula cells ........ r694643 | josh | 2008-09-12 09:18:54 +0100 (Fri, 12 Sep 2008) | 2 lines Made HSSFFormulaEvaluator no longer require initialisation with sheet or row. ........ r694877 | josh | 2008-09-13 06:14:26 +0100 (Sat, 13 Sep 2008) | 1 line Refactored TextFunctions. Some minor fixes - test cases added. ........ r694881 | josh | 2008-09-13 06:43:41 +0100 (Sat, 13 Sep 2008) | 1 line Added toString methods formatAsString to CellValue. Changed deprecation on CellValue.getRichTextStringValue ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@694947 13f79535-47bb-0310-9956-ffa450edef68
2008-09-13 09:48:27 -04:00
import org.apache.poi.hssf.record.UnicodeString;
import org.apache.poi.hssf.record.constant.ErrorConstant;
import org.apache.poi.hssf.record.formula.*;
import org.apache.poi.hssf.record.formula.ValueOperatorPtg;
Merged revisions 612484-612511,612513-612519,612521-613394,613397-613399,613402-614210,614212-614273,614275-614869,614871-614877,614879-614908,614910-615189,615191-615254,615256-615258,615260-615309,615311-615314,615316-615609,615611-615768,615770-615858,615860-617155,617157-617166,617168-617482,617484-617486,617488-617490,617492-617515,617517-617522,617524-617554,617556-617833,617835-618229,618231-618234,618236-618327,618329-618679,618681-618689,618691,618693-618939,618941-619000,619002-619309,619311-619381,619383-619501,619503-619508,619510-619847,619850,619852-619967,619969-620340,620342-620556,620558-620581,620583-627778,627780-627787,627789-627998,628000-628026,628028,628030-628032,628034,628036-628043,628045-628064,628066-628713,628715-629551,629553-629737,629739-629741,629743-629754,629756-629820,629822-629828,629830,629833-629836,629838-629848,629850-629864,629866-630159,630161-630163,630165-633113,633115-633117,633119-633125,633127-633150,633152-633168,633170-633204,633206-633504,633506-633546,633549-634317,634319-634370,634373-634616,634618,634620-634629,634631-636750,636752-636755,636757-636785,636787-636789,636791-637188,637190-637592,637594,637596-637597,637599,637602-637869,637871-638784,638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-640056,640058-642557 via svnmerge from https://svn.apache.org/repos/asf/poi/trunk ........ r639918 | josh | 2008-03-21 23:47:51 +0000 (Fri, 21 Mar 2008) | 1 line sort to int conversion sign extension fix ........ r640711 | josh | 2008-03-25 06:18:33 +0000 (Tue, 25 Mar 2008) | 1 line Added class javadoc. Patch 30311 from Dmtriy. ........ r641157 | josh | 2008-03-26 05:29:08 +0000 (Wed, 26 Mar 2008) | 1 line more javadoc + clean-up from Dmitriy (bug 30311 att 21711) ........ r641185 | josh | 2008-03-26 07:32:28 +0000 (Wed, 26 Mar 2008) | 1 line patch 44675 - made POI capable of recognising var-args functions. Some related fixes. ........ r641796 | nick | 2008-03-27 12:48:55 +0000 (Thu, 27 Mar 2008) | 1 line Patch from Raghu from bug #44652 - Improved handling of Pictures in Word Documents ........ r641799 | nick | 2008-03-27 12:54:32 +0000 (Thu, 27 Mar 2008) | 1 line Fix typo, and point hwpf people at the new microsoft docs ........ r641934 | nick | 2008-03-27 18:24:39 +0000 (Thu, 27 Mar 2008) | 1 line Add failing (but disabled) test from bug #44691 ........ r641964 | josh | 2008-03-27 20:03:29 +0000 (Thu, 27 Mar 2008) | 1 line fixes for ExternalNameRecord serialisation bug #44691 ........ r641967 | josh | 2008-03-27 20:15:13 +0000 (Thu, 27 Mar 2008) | 1 line annotated previous changelist(641964) with wrong buzilla number. Previous changes were for bug #44695. ........ r641996 | josh | 2008-03-27 21:54:21 +0000 (Thu, 27 Mar 2008) | 1 line (real) fix for bug #44691. Modified Pmt.java to allow for 3 arguments. Added TestPmt junit. ........ r642231 | nick | 2008-03-28 13:35:37 +0000 (Fri, 28 Mar 2008) | 1 line Add test to show that bug #44693 is incorrect ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@642560 13f79535-47bb-0310-9956-ffa450edef68
2008-03-29 13:19:09 -04:00
import org.apache.poi.hssf.record.formula.function.FunctionMetadata;
import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry;
Merged revisions 693591,693639,693658,693939,693941,693947,693990,694050,694065,694153,694534,694615,694619-694620,694631,694643,694877,694881 via svnmerge from https://svn.apache.org/repos/asf/poi/trunk ........ r693591 | josh | 2008-09-09 21:25:16 +0100 (Tue, 09 Sep 2008) | 1 line Added support for parsing array constants in formulas. (Helping investigation for bug 45752) ........ r693639 | josh | 2008-09-09 23:26:28 +0100 (Tue, 09 Sep 2008) | 1 line removed debug code accidentally submitted with r693591 ........ r693658 | josh | 2008-09-10 00:46:46 +0100 (Wed, 10 Sep 2008) | 2 lines Fixed special cases of INDEX function (single columns / single rows, and errors) ........ r693939 | josh | 2008-09-10 20:23:43 +0100 (Wed, 10 Sep 2008) | 1 line Fixing error value handling for numeric functions. Refactored hierarchy. ........ r693941 | josh | 2008-09-10 20:27:24 +0100 (Wed, 10 Sep 2008) | 1 line (Should have been submitted with 693939) Fixing error value handling for numeric functions. Refactored hierarchy. ........ r693947 | josh | 2008-09-10 20:33:58 +0100 (Wed, 10 Sep 2008) | 1 line (Should have been submitted with 693939) Fixing error value handling for numeric functions. Refactored hierarchy. ........ r693990 | josh | 2008-09-10 22:21:28 +0100 (Wed, 10 Sep 2008) | 1 line Refactored hierarchy of MultiOperandNumericFunction. Fixed error value handling. Enabled error value check in TestFormulasFromSpreadsheet ........ r694050 | josh | 2008-09-10 23:43:30 +0100 (Wed, 10 Sep 2008) | 1 line Refactored finance functions. ........ r694065 | josh | 2008-09-11 00:37:22 +0100 (Thu, 11 Sep 2008) | 1 line fixed special cases of MODE function ........ r694153 | josh | 2008-09-11 08:16:20 +0100 (Thu, 11 Sep 2008) | 1 line Refactoring MultiOperandNumericFunction - removed Ref2DEval. ........ r694534 | josh | 2008-09-12 00:18:50 +0100 (Fri, 12 Sep 2008) | 1 line Fix for bug 45639 - cleaned up index logic inside ColumnInfoRecordsAggregate ........ r694615 | josh | 2008-09-12 07:14:07 +0100 (Fri, 12 Sep 2008) | 1 line small tweak to unit test which was silently creating UnknownPtgs ........ r694619 | josh | 2008-09-12 07:58:52 +0100 (Fri, 12 Sep 2008) | 1 line Removed trailing comma from output of HexDump.toHex() ........ r694620 | josh | 2008-09-12 08:03:00 +0100 (Fri, 12 Sep 2008) | 1 line clarification of ArrayPtg size increment ........ r694631 | josh | 2008-09-12 08:43:20 +0100 (Fri, 12 Sep 2008) | 1 line Extended support for cached results of formula cells ........ r694643 | josh | 2008-09-12 09:18:54 +0100 (Fri, 12 Sep 2008) | 2 lines Made HSSFFormulaEvaluator no longer require initialisation with sheet or row. ........ r694877 | josh | 2008-09-13 06:14:26 +0100 (Sat, 13 Sep 2008) | 1 line Refactored TextFunctions. Some minor fixes - test cases added. ........ r694881 | josh | 2008-09-13 06:43:41 +0100 (Sat, 13 Sep 2008) | 1 line Added toString methods formatAsString to CellValue. Changed deprecation on CellValue.getRichTextStringValue ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@694947 13f79535-47bb-0310-9956-ffa450edef68
2008-09-13 09:48:27 -04:00
import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.util.CellReference.NameType;
/**
* This class parses a formula string into a List of tokens in RPN order.
Merged revisions 627779-634630 via svnmerge from https://svn.apache.org/repos/asf/poi/trunk ........ r627779 | nick | 2008-02-14 16:32:49 +0100 (Thu, 14 Feb 2008) | 1 line In the interests of sanity, stop having hssf test data files in scratchpad and main, go to just having them in main ........ r627788 | nick | 2008-02-14 17:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Big formula update from Josh from bug #44364 - support for Match, NA and SumProduct functions, and initial error support in functions ........ r627999 | nick | 2008-02-15 11:30:10 +0100 (Fri, 15 Feb 2008) | 1 line To avoid confusion and repeated changes in svn, update the TestDataValidation test to output its file (that needs opening in excel to check to output) into the system tmp directory ........ r628027 | nick | 2008-02-15 12:45:13 +0100 (Fri, 15 Feb 2008) | 1 line Fix for bug #44403 - Have mid use the third argument properly, and test ........ r628029 | nick | 2008-02-15 12:53:25 +0100 (Fri, 15 Feb 2008) | 1 line Fix for bug #44413 from Josh - Fix for circular references in INDEX, OFFSET, VLOOKUP formulas, where a cell is actually allowed to reference itself ........ r628033 | nick | 2008-02-15 13:04:42 +0100 (Fri, 15 Feb 2008) | 1 line Fix from Josh from bug #44417 - Improved handling of references for the need to quote the sheet name for some formulas, but not when fetching a sheet by name ........ r628035 | nick | 2008-02-15 13:13:25 +0100 (Fri, 15 Feb 2008) | 1 line Fix from Josh from bug #44421 - Update Match function to properly support Area references ........ r628044 | nick | 2008-02-15 13:59:40 +0100 (Fri, 15 Feb 2008) | 1 line Partial fix for bug #44410 - support whole column ranges such as C:C in the formula evaluator (so SUM(D:D) will now work). However, the formula string will still be displayed wrong ........ r628065 | nick | 2008-02-15 14:50:38 +0100 (Fri, 15 Feb 2008) | 1 line Further support for whole-column references, including formula strings and the evaluator. Also has some new tests for it ........ r628714 | nick | 2008-02-18 14:08:16 +0100 (Mon, 18 Feb 2008) | 1 line Update notice for latest guidance on ooxml xsd licence, and update getting involved to link to the newly released binary file format docs ........ r629552 | nick | 2008-02-20 19:14:30 +0100 (Wed, 20 Feb 2008) | 1 line Patch from Josh from bug #44403 - Further support for unusual, but valid, arguments to the Mid function ........ r629738 | nick | 2008-02-21 11:36:08 +0100 (Thu, 21 Feb 2008) | 1 line Fix from Josh from bug #44456 - Update contrib SViewer to not fail if a HSSFRow is null ........ r629742 | nick | 2008-02-21 11:49:25 +0100 (Thu, 21 Feb 2008) | 1 line Use the right way to figure out how many rows on a sheet, so we display the row number for all of them on the left hand side. Also, tidy up some imports ........ r629755 | nick | 2008-02-21 12:34:25 +0100 (Thu, 21 Feb 2008) | 1 line Fix bug 38921, where HSSFPalette.findSimilar() wasn't working properly, and add tests for it ........ r629821 | nick | 2008-02-21 16:08:44 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44371 - support for OFFSET function, and various tweaks to the formula evaluator to support this ........ r629829 | nick | 2008-02-21 16:35:59 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44366 - InputStreams passed to POIFSFileSystem are now automatically closed. A warning is generated for people who might've relied on them not being closed before, and a wrapper to restore the old behaviour is supplied ........ r629831 | nick | 2008-02-21 16:40:34 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44437 - improved unit test for poifs ........ r629832 | nick | 2008-02-21 16:42:06 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44437 - improved unit test for poifs ........ r629837 | nick | 2008-02-21 16:48:52 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44449 - Handle SharedFormulas better, for where there are formulas for the same area on two sheets, and when the shared formula flag is set incorrectly ........ r629849 | nick | 2008-02-21 17:22:18 +0100 (Thu, 21 Feb 2008) | 1 line Add a disabled test for a file with whacky StyleRecords that trigger an AIOOB ........ r629865 | nick | 2008-02-21 17:44:46 +0100 (Thu, 21 Feb 2008) | 1 line At the request of legal-discuss, shuffle the ooxml xsd licence details into LICENSE from NOTICE ........ r630160 | nick | 2008-02-22 12:23:50 +0100 (Fri, 22 Feb 2008) | 1 line Patch from Josh from bug #44450 - VLookup and HLookup support, and improvements to Lookup and Offset ........ r630164 | nick | 2008-02-22 12:40:00 +0100 (Fri, 22 Feb 2008) | 1 line Bug #44471 - Crystal Reports generates files with short StyleRecords, which isn't allowed in the spec. Work around this ........ r633114 | nick | 2008-03-03 16:01:18 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Paolo from bug #44481 - getVerticallyCenter shouldn't take a parameter, but leave the old version in as deprecated for now ........ r633118 | nick | 2008-03-03 16:10:46 +0100 (Mon, 03 Mar 2008) | 1 line Fix from Yegor from bug #44491 - don't have the new style handy POIDocument property stuff break old style hpsf+hssf use ........ r633126 | nick | 2008-03-03 16:26:38 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Josh from bug #44495 - Handle named cell ranges in formulas that have lower case parts ........ r633151 | nick | 2008-03-03 17:09:02 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Josh from bug #44510 - Fix how DVALRecord works with dropdowns ........ r633169 | nick | 2008-03-03 17:55:00 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Josh from bug #44508 - Fix formula evaluation with evaluateInCell on boolean formulas ........ r633205 | nick | 2008-03-03 18:47:36 +0100 (Mon, 03 Mar 2008) | 1 line Fix indent, add more documentation, and make the error message more helpful ........ r633505 | nick | 2008-03-04 16:06:29 +0100 (Tue, 04 Mar 2008) | 1 line Problem files from bug #44501 ........ r633547 | nick | 2008-03-04 17:53:32 +0100 (Tue, 04 Mar 2008) | 1 line Big patch from Josh from bug #44504 - lots of formula parser improvements ........ r633548 | nick | 2008-03-04 17:59:02 +0100 (Tue, 04 Mar 2008) | 1 line Changelog update for last patch ........ r634318 | nick | 2008-03-06 16:54:06 +0100 (Thu, 06 Mar 2008) | 1 line Change the behaviour on short last blocks to be a warning not an exception, as some people seem to have "real" valid files that trigger this. Fixed bug #28231 ........ r634371 | nick | 2008-03-06 19:06:48 +0100 (Thu, 06 Mar 2008) | 1 line Embeded files from bug #44524 ........ r634372 | nick | 2008-03-06 19:13:47 +0100 (Thu, 06 Mar 2008) | 1 line Add broken test for bug #43901 ........ r634617 | nick | 2008-03-07 12:18:02 +0100 (Fri, 07 Mar 2008) | 1 line Patch from Josh from bug #43901 - Correctly update the internal last cell number when adding and removing cells (previously sometimes off-by-one) ........ r634619 | nick | 2008-03-07 12:36:14 +0100 (Fri, 07 Mar 2008) | 1 line Improved support for read-only recommended workbooks, fixing bug #44536 ........ r634630 | nick | 2008-03-07 13:06:18 +0100 (Fri, 07 Mar 2008) | 1 line Patch largely from Josh from bug #44539 - Support for area references in formulas of rows >= 32768 ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@634936 13f79535-47bb-0310-9956-ffa450edef68
2008-03-08 06:49:00 -05:00
* Inspired by
* Lets Build a Compiler, by Jack Crenshaw
* BNF for the formula expression is :
* <expression> ::= <term> [<addop> <term>]*
* <term> ::= <factor> [ <mulop> <factor> ]*
* <factor> ::= <number> | (<expression>) | <cellRef> | <function>
* <function> ::= <functionName> ([expression [, expression]*])
*
* @author Avik Sengupta <avik at apache dot org>
* @author Andrew C. oliver (acoliver at apache dot org)
* @author Eric Ladner (eladner at goldinc dot com)
* @author Cameron Riley (criley at ekmail.com)
* @author Peter M. Murray (pete at quantrix dot com)
* @author Pavel Krupets (pkrupets at palmtreebusiness dot com)
* @author Josh Micich
*/
Merged revisions 627779-634630 via svnmerge from https://svn.apache.org/repos/asf/poi/trunk ........ r627779 | nick | 2008-02-14 16:32:49 +0100 (Thu, 14 Feb 2008) | 1 line In the interests of sanity, stop having hssf test data files in scratchpad and main, go to just having them in main ........ r627788 | nick | 2008-02-14 17:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Big formula update from Josh from bug #44364 - support for Match, NA and SumProduct functions, and initial error support in functions ........ r627999 | nick | 2008-02-15 11:30:10 +0100 (Fri, 15 Feb 2008) | 1 line To avoid confusion and repeated changes in svn, update the TestDataValidation test to output its file (that needs opening in excel to check to output) into the system tmp directory ........ r628027 | nick | 2008-02-15 12:45:13 +0100 (Fri, 15 Feb 2008) | 1 line Fix for bug #44403 - Have mid use the third argument properly, and test ........ r628029 | nick | 2008-02-15 12:53:25 +0100 (Fri, 15 Feb 2008) | 1 line Fix for bug #44413 from Josh - Fix for circular references in INDEX, OFFSET, VLOOKUP formulas, where a cell is actually allowed to reference itself ........ r628033 | nick | 2008-02-15 13:04:42 +0100 (Fri, 15 Feb 2008) | 1 line Fix from Josh from bug #44417 - Improved handling of references for the need to quote the sheet name for some formulas, but not when fetching a sheet by name ........ r628035 | nick | 2008-02-15 13:13:25 +0100 (Fri, 15 Feb 2008) | 1 line Fix from Josh from bug #44421 - Update Match function to properly support Area references ........ r628044 | nick | 2008-02-15 13:59:40 +0100 (Fri, 15 Feb 2008) | 1 line Partial fix for bug #44410 - support whole column ranges such as C:C in the formula evaluator (so SUM(D:D) will now work). However, the formula string will still be displayed wrong ........ r628065 | nick | 2008-02-15 14:50:38 +0100 (Fri, 15 Feb 2008) | 1 line Further support for whole-column references, including formula strings and the evaluator. Also has some new tests for it ........ r628714 | nick | 2008-02-18 14:08:16 +0100 (Mon, 18 Feb 2008) | 1 line Update notice for latest guidance on ooxml xsd licence, and update getting involved to link to the newly released binary file format docs ........ r629552 | nick | 2008-02-20 19:14:30 +0100 (Wed, 20 Feb 2008) | 1 line Patch from Josh from bug #44403 - Further support for unusual, but valid, arguments to the Mid function ........ r629738 | nick | 2008-02-21 11:36:08 +0100 (Thu, 21 Feb 2008) | 1 line Fix from Josh from bug #44456 - Update contrib SViewer to not fail if a HSSFRow is null ........ r629742 | nick | 2008-02-21 11:49:25 +0100 (Thu, 21 Feb 2008) | 1 line Use the right way to figure out how many rows on a sheet, so we display the row number for all of them on the left hand side. Also, tidy up some imports ........ r629755 | nick | 2008-02-21 12:34:25 +0100 (Thu, 21 Feb 2008) | 1 line Fix bug 38921, where HSSFPalette.findSimilar() wasn't working properly, and add tests for it ........ r629821 | nick | 2008-02-21 16:08:44 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44371 - support for OFFSET function, and various tweaks to the formula evaluator to support this ........ r629829 | nick | 2008-02-21 16:35:59 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44366 - InputStreams passed to POIFSFileSystem are now automatically closed. A warning is generated for people who might've relied on them not being closed before, and a wrapper to restore the old behaviour is supplied ........ r629831 | nick | 2008-02-21 16:40:34 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44437 - improved unit test for poifs ........ r629832 | nick | 2008-02-21 16:42:06 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44437 - improved unit test for poifs ........ r629837 | nick | 2008-02-21 16:48:52 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44449 - Handle SharedFormulas better, for where there are formulas for the same area on two sheets, and when the shared formula flag is set incorrectly ........ r629849 | nick | 2008-02-21 17:22:18 +0100 (Thu, 21 Feb 2008) | 1 line Add a disabled test for a file with whacky StyleRecords that trigger an AIOOB ........ r629865 | nick | 2008-02-21 17:44:46 +0100 (Thu, 21 Feb 2008) | 1 line At the request of legal-discuss, shuffle the ooxml xsd licence details into LICENSE from NOTICE ........ r630160 | nick | 2008-02-22 12:23:50 +0100 (Fri, 22 Feb 2008) | 1 line Patch from Josh from bug #44450 - VLookup and HLookup support, and improvements to Lookup and Offset ........ r630164 | nick | 2008-02-22 12:40:00 +0100 (Fri, 22 Feb 2008) | 1 line Bug #44471 - Crystal Reports generates files with short StyleRecords, which isn't allowed in the spec. Work around this ........ r633114 | nick | 2008-03-03 16:01:18 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Paolo from bug #44481 - getVerticallyCenter shouldn't take a parameter, but leave the old version in as deprecated for now ........ r633118 | nick | 2008-03-03 16:10:46 +0100 (Mon, 03 Mar 2008) | 1 line Fix from Yegor from bug #44491 - don't have the new style handy POIDocument property stuff break old style hpsf+hssf use ........ r633126 | nick | 2008-03-03 16:26:38 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Josh from bug #44495 - Handle named cell ranges in formulas that have lower case parts ........ r633151 | nick | 2008-03-03 17:09:02 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Josh from bug #44510 - Fix how DVALRecord works with dropdowns ........ r633169 | nick | 2008-03-03 17:55:00 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Josh from bug #44508 - Fix formula evaluation with evaluateInCell on boolean formulas ........ r633205 | nick | 2008-03-03 18:47:36 +0100 (Mon, 03 Mar 2008) | 1 line Fix indent, add more documentation, and make the error message more helpful ........ r633505 | nick | 2008-03-04 16:06:29 +0100 (Tue, 04 Mar 2008) | 1 line Problem files from bug #44501 ........ r633547 | nick | 2008-03-04 17:53:32 +0100 (Tue, 04 Mar 2008) | 1 line Big patch from Josh from bug #44504 - lots of formula parser improvements ........ r633548 | nick | 2008-03-04 17:59:02 +0100 (Tue, 04 Mar 2008) | 1 line Changelog update for last patch ........ r634318 | nick | 2008-03-06 16:54:06 +0100 (Thu, 06 Mar 2008) | 1 line Change the behaviour on short last blocks to be a warning not an exception, as some people seem to have "real" valid files that trigger this. Fixed bug #28231 ........ r634371 | nick | 2008-03-06 19:06:48 +0100 (Thu, 06 Mar 2008) | 1 line Embeded files from bug #44524 ........ r634372 | nick | 2008-03-06 19:13:47 +0100 (Thu, 06 Mar 2008) | 1 line Add broken test for bug #43901 ........ r634617 | nick | 2008-03-07 12:18:02 +0100 (Fri, 07 Mar 2008) | 1 line Patch from Josh from bug #43901 - Correctly update the internal last cell number when adding and removing cells (previously sometimes off-by-one) ........ r634619 | nick | 2008-03-07 12:36:14 +0100 (Fri, 07 Mar 2008) | 1 line Improved support for read-only recommended workbooks, fixing bug #44536 ........ r634630 | nick | 2008-03-07 13:06:18 +0100 (Fri, 07 Mar 2008) | 1 line Patch largely from Josh from bug #44539 - Support for area references in formulas of rows >= 32768 ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@634936 13f79535-47bb-0310-9956-ffa450edef68
2008-03-08 06:49:00 -05:00
public final class FormulaParser {
private static final class Identifier {
private final String _name;
private final boolean _isQuoted;
public Identifier(String name, boolean isQuoted) {
_name = name;
_isQuoted = isQuoted;
}
public String getName() {
return _name;
}
public boolean isQuoted() {
return _isQuoted;
}
public String toString() {
StringBuffer sb = new StringBuffer(64);
sb.append(getClass().getName());
sb.append(" [");
if (_isQuoted) {
sb.append("'").append(_name).append("'");
} else {
sb.append(_name);
}
sb.append("]");
return sb.toString();
}
}
private static final class SheetIdentifier {
private final String _bookName;
private final Identifier _sheetIdentifier;
public SheetIdentifier(String bookName, Identifier sheetIdentifier) {
_bookName = bookName;
_sheetIdentifier = sheetIdentifier;
}
public String getBookName() {
return _bookName;
}
public Identifier getSheetIdentifier() {
return _sheetIdentifier;
}
public String toString() {
StringBuffer sb = new StringBuffer(64);
sb.append(getClass().getName());
sb.append(" [");
if (_bookName != null) {
sb.append(" [").append(_sheetIdentifier.getName()).append("]");
}
if (_sheetIdentifier.isQuoted()) {
sb.append("'").append(_sheetIdentifier.getName()).append("'");
} else {
sb.append(_sheetIdentifier.getName());
}
sb.append("]");
return sb.toString();
}
}
/**
* Specific exception thrown when a supplied formula does not parse properly.<br/>
* Primarily used by test cases when testing for specific parsing exceptions.</p>
*
*/
static final class FormulaParseException extends RuntimeException {
// This class was given package scope until it would become clear that it is useful to
// general client code.
public FormulaParseException(String msg) {
super(msg);
}
}
private final String _formulaString;
private final int _formulaLength;
/** points at the next character to be read (after the {@link #look} char) */
private int _pointer;
private ParseNode _rootNode;
private static char TAB = '\t';
/**
* Lookahead Character.
* gets value '\0' when the input string is exhausted
*/
private char look;
private FormulaParsingWorkbook _book;
private int _sheetIndex;
/**
* Create the formula parser, with the string that is to be
* parsed against the supplied workbook.
* A later call the parse() method to return ptg list in
* rpn order, then call the getRPNPtg() to retrieve the
* parse results.
* This class is recommended only for single threaded use.
*
* If you only have a usermodel.HSSFWorkbook, and not a
* model.Workbook, then use the convenience method on
* usermodel.HSSFFormulaEvaluator
*/
private FormulaParser(String formula, FormulaParsingWorkbook book, int sheetIndex){
_formulaString = formula;
_pointer=0;
_book = book;
_formulaLength = _formulaString.length();
_sheetIndex = sheetIndex;
}
public static Ptg[] parse(String formula, FormulaParsingWorkbook book) {
return parse(formula, book, FormulaType.CELL);
}
public static Ptg[] parse(String formula, FormulaParsingWorkbook workbook, int formulaType) {
return parse(formula, workbook, formulaType, -1);
}
/**
* Parse a formula into a array of tokens
*
* @param formula the formula to parse
* @param workbook the parent workbook
* @param formulaType the type of the formula, see {@link FormulaType}
* @param sheetIndex the 0-based index of the sheet this formula belongs to.
* The sheet index is required to resolve sheet-level names. <code>-1</code> means that
* the scope of the name will be ignored and the parser will match names only by name
*
* @return array of parsed tokens
* @throws FormulaParseException if the formula is unparsable
*/
public static Ptg[] parse(String formula, FormulaParsingWorkbook workbook, int formulaType, int sheetIndex) {
FormulaParser fp = new FormulaParser(formula, workbook, sheetIndex);
fp.parse();
return fp.getRPNPtg(formulaType);
}
/** Read New Character From Input Stream */
private void GetChar() {
// Check to see if we've walked off the end of the string.
if (_pointer > _formulaLength) {
throw new RuntimeException("too far");
}
if (_pointer < _formulaLength) {
look=_formulaString.charAt(_pointer);
} else {
// Just return if so and reset 'look' to something to keep
// SkipWhitespace from spinning
look = (char)0;
}
_pointer++;
//System.out.println("Got char: "+ look);
}
private void resetPointer(int ptr) {
_pointer = ptr;
if (_pointer <= _formulaLength) {
look=_formulaString.charAt(_pointer-1);
} else {
// Just return if so and reset 'look' to something to keep
// SkipWhitespace from spinning
look = (char)0;
}
}
/** Report What Was Expected */
private RuntimeException expected(String s) {
String msg;
if (look == '=' && _formulaString.substring(0, _pointer-1).trim().length() < 1) {
msg = "The specified formula '" + _formulaString
+ "' starts with an equals sign which is not allowed.";
} else {
msg = "Parse error near char " + (_pointer-1) + " '" + look + "'"
+ " in specified formula '" + _formulaString + "'. Expected "
+ s;
}
return new FormulaParseException(msg);
}
/** Recognize an Alpha Character */
private static boolean IsAlpha(char c) {
return Character.isLetter(c) || c == '$' || c=='_';
}
/** Recognize a Decimal Digit */
private static boolean IsDigit(char c) {
return Character.isDigit(c);
}
/** Recognize White Space */
private static boolean IsWhite( char c) {
return c ==' ' || c== TAB;
}
/** Skip Over Leading White Space */
private void SkipWhite() {
while (IsWhite(look)) {
GetChar();
}
}
/**
* Consumes the next input character if it is equal to the one specified otherwise throws an
* unchecked exception. This method does <b>not</b> consume whitespace (before or after the
* matched character).
*/
private void Match(char x) {
if (look != x) {
throw expected("'" + x + "'");
}
GetChar();
}
/** Get a Number */
private String GetNum() {
StringBuffer value = new StringBuffer();
while (IsDigit(this.look)){
value.append(this.look);
GetChar();
}
return value.length() == 0 ? null : value.toString();
}
private ParseNode parseRangeExpression() {
ParseNode result = parseRangeable();
boolean hasRange = false;
while (look == ':') {
int pos = _pointer;
GetChar();
ParseNode nextPart = parseRangeable();
// Note - no range simplification here. An expr like "A1:B2:C3:D4:E5" should be
// grouped into area ref pairs like: "(A1:B2):(C3:D4):E5"
// Furthermore, Excel doesn't seem to simplify
// expressions like "Sheet1!A1:Sheet1:B2" into "Sheet1!A1:B2"
checkValidRangeOperand("LHS", pos, result);
checkValidRangeOperand("RHS", pos, nextPart);
ParseNode[] children = { result, nextPart, };
result = new ParseNode(RangePtg.instance, children);
hasRange = true;
}
if (hasRange) {
return augmentWithMemPtg(result);
}
return result;
}
private static ParseNode augmentWithMemPtg(ParseNode root) {
Ptg memPtg;
if (needsMemFunc(root)) {
memPtg = new MemFuncPtg(root.getEncodedSize());
} else {
memPtg = new MemAreaPtg(root.getEncodedSize());
}
return new ParseNode(memPtg, root);
}
/**
* From OOO doc: "Whenever one operand of the reference subexpression is a function,
* a defined name, a 3D reference, or an external reference (and no error occurs),
* a tMemFunc token is used"
*
*/
private static boolean needsMemFunc(ParseNode root) {
Ptg token = root.getToken();
if (token instanceof AbstractFunctionPtg) {
return true;
}
if (token instanceof ExternSheetReferenceToken) { // 3D refs
return true;
}
if (token instanceof NamePtg || token instanceof NameXPtg) { // 3D refs
return true;
}
if (token instanceof OperationPtg || token instanceof ParenthesisPtg) {
// expect RangePtg, but perhaps also UnionPtg, IntersectionPtg etc
for(ParseNode child : root.getChildren()) {
if (needsMemFunc(child)) {
return true;
}
}
return false;
}
if (token instanceof OperandPtg) {
return false;
}
if (token instanceof OperationPtg) {
return true;
}
return false;
}
/**
* @param currentParsePosition used to format a potential error message
*/
private static void checkValidRangeOperand(String sideName, int currentParsePosition, ParseNode pn) {
if (!isValidRangeOperand(pn)) {
throw new FormulaParseException("The " + sideName
+ " of the range operator ':' at position "
+ currentParsePosition + " is not a proper reference.");
}
}
/**
* @return <code>false</code> if sub-expression represented the specified ParseNode definitely
* cannot appear on either side of the range (':') operator
*/
private static boolean isValidRangeOperand(ParseNode a) {
Ptg tkn = a.getToken();
// Note - order is important for these instance-of checks
if (tkn instanceof OperandPtg) {
// notably cell refs and area refs
return true;
}
// next 2 are special cases of OperationPtg
if (tkn instanceof AbstractFunctionPtg) {
AbstractFunctionPtg afp = (AbstractFunctionPtg) tkn;
byte returnClass = afp.getDefaultOperandClass();
return Ptg.CLASS_REF == returnClass;
}
if (tkn instanceof ValueOperatorPtg) {
return false;
}
if (tkn instanceof OperationPtg) {
return true;
}
// one special case of ControlPtg
if (tkn instanceof ParenthesisPtg) {
// parenthesis Ptg should have only one child
return isValidRangeOperand(a.getChildren()[0]);
}
// one special case of ScalarConstantPtg
if (tkn == ErrPtg.REF_INVALID) {
return true;
}
// All other ControlPtgs and ScalarConstantPtgs cannot be used with ':'
return false;
}
/**
* Parses area refs (things which could be the operand of ':') and simple factors
* Examples
* <pre>
* A$1
* $A$1 : $B1
* A1 ....... C2
* Sheet1 !$A1
* a..b!A1
* 'my sheet'!A1
* .my.sheet!A1
* my.named..range.
* foo.bar(123.456, "abc")
* 123.456
* "abc"
* true
* </pre>
*
*/
private ParseNode parseRangeable() {
SkipWhite();
int savePointer = _pointer;
SheetIdentifier sheetIden = parseSheetName();
if (sheetIden == null) {
resetPointer(savePointer);
} else {
SkipWhite();
savePointer = _pointer;
}
SimpleRangePart part1 = parseSimpleRangePart();
if (part1 == null) {
if (sheetIden != null) {
throw new FormulaParseException("Cell reference expected after sheet name at index "
+ _pointer + ".");
}
return parseNonRange(savePointer);
}
boolean whiteAfterPart1 = IsWhite(look);
if (whiteAfterPart1) {
SkipWhite();
}
if (look == ':') {
int colonPos = _pointer;
GetChar();
SkipWhite();
SimpleRangePart part2 = parseSimpleRangePart();
if (part2 != null && !part1.isCompatibleForArea(part2)) {
// second part is not compatible with an area ref e.g. S!A1:S!B2
// where S might be a sheet name (that looks like a column name)
part2 = null;
}
if (part2 == null) {
// second part is not compatible with an area ref e.g. A1:OFFSET(B2, 1, 2)
// reset and let caller use explicit range operator
resetPointer(colonPos);
if (!part1.isCell()) {
String prefix;
if (sheetIden == null) {
prefix = "";
} else {
prefix = "'" + sheetIden.getSheetIdentifier().getName() + '!';
}
throw new FormulaParseException(prefix + part1.getRep() + "' is not a proper reference.");
}
return createAreaRefParseNode(sheetIden, part1, part2);
}
return createAreaRefParseNode(sheetIden, part1, part2);
}
if (look == '.') {
GetChar();
int dotCount = 1;
while (look =='.') {
dotCount ++;
GetChar();
}
boolean whiteBeforePart2 = IsWhite(look);
SkipWhite();
SimpleRangePart part2 = parseSimpleRangePart();
String part1And2 = _formulaString.substring(savePointer-1, _pointer-1);
if (part2 == null) {
if (sheetIden != null) {
throw new FormulaParseException("Complete area reference expected after sheet name at index "
+ _pointer + ".");
}
return parseNonRange(savePointer);
}
if (whiteAfterPart1 || whiteBeforePart2) {
if (part1.isRowOrColumn() || part2.isRowOrColumn()) {
// "A .. B" not valid syntax for "A:B"
// and there's no other valid expression that fits this grammar
throw new FormulaParseException("Dotted range (full row or column) expression '"
+ part1And2 + "' must not contain whitespace.");
}
return createAreaRefParseNode(sheetIden, part1, part2);
}
if (dotCount == 1 && part1.isRow() && part2.isRow()) {
// actually, this is looking more like a number
return parseNonRange(savePointer);
}
if (part1.isRowOrColumn() || part2.isRowOrColumn()) {
if (dotCount != 2) {
throw new FormulaParseException("Dotted range (full row or column) expression '" + part1And2
+ "' must have exactly 2 dots.");
}
}
return createAreaRefParseNode(sheetIden, part1, part2);
}
if (part1.isCell() && isValidCellReference(part1.getRep())) {
return createAreaRefParseNode(sheetIden, part1, null);
}
if (sheetIden != null) {
throw new FormulaParseException("Second part of cell reference expected after sheet name at index "
+ _pointer + ".");
}
return parseNonRange(savePointer);
}
/**
* Parses simple factors that are not primitive ranges or range components
* i.e. '!', ':'(and equiv '...') do not appear
* Examples
* <pre>
* my.named...range.
* foo.bar(123.456, "abc")
* 123.456
* "abc"
* true
* </pre>
*/
private ParseNode parseNonRange(int savePointer) {
resetPointer(savePointer);
if (Character.isDigit(look)) {
return new ParseNode(parseNumber());
}
if (look == '"') {
return new ParseNode(new StringPtg(parseStringLiteral()));
}
// from now on we can only be dealing with non-quoted identifiers
// which will either be named ranges or functions
StringBuilder sb = new StringBuilder();
if (!Character.isLetter(look)) {
throw expected("number, string, or defined name");
}
while (isValidDefinedNameChar(look)) {
sb.append(look);
GetChar();
}
SkipWhite();
String name = sb.toString();
if (look == '(') {
return function(name);
}
if (name.equalsIgnoreCase("TRUE") || name.equalsIgnoreCase("FALSE")) {
return new ParseNode(new BoolPtg(name.toUpperCase()));
}
if (_book == null) {
// Only test cases omit the book (expecting it not to be needed)
throw new IllegalStateException("Need book to evaluate name '" + name + "'");
}
EvaluationName evalName = _book.getName(name, _sheetIndex);
if (evalName == null) {
throw new FormulaParseException("Specified named range '"
+ name + "' does not exist in the current workbook.");
}
if (evalName.isRange()) {
return new ParseNode(evalName.createPtg());
}
// TODO - what about NameX ?
throw new FormulaParseException("Specified name '"
+ name + "' is not a range as expected.");
}
/**
*
* @return <code>true</code> if the specified character may be used in a defined name
*/
private static boolean isValidDefinedNameChar(char ch) {
if (Character.isLetterOrDigit(ch)) {
return true;
}
switch (ch) {
case '.':
case '_':
case '?':
case '\\': // of all things
return true;
}
return false;
}
/**
*
* @param sheetIden may be <code>null</code>
* @param part1
* @param part2 may be <code>null</code>
*/
private ParseNode createAreaRefParseNode(SheetIdentifier sheetIden, SimpleRangePart part1,
SimpleRangePart part2) throws FormulaParseException {
int extIx;
if (sheetIden == null) {
extIx = Integer.MIN_VALUE;
} else {
String sName = sheetIden.getSheetIdentifier().getName();
if (sheetIden.getBookName() == null) {
extIx = _book.getExternalSheetIndex(sName);
} else {
extIx = _book.getExternalSheetIndex(sheetIden.getBookName(), sName);
}
}
Ptg ptg;
if (part2 == null) {
CellReference cr = part1.getCellReference();
if (sheetIden == null) {
ptg = new RefPtg(cr);
} else {
ptg = new Ref3DPtg(cr, extIx);
}
} else {
AreaReference areaRef = createAreaRef(part1, part2);
if (sheetIden == null) {
ptg = new AreaPtg(areaRef);
} else {
ptg = new Area3DPtg(areaRef, extIx);
}
}
return new ParseNode(ptg);
}
private static AreaReference createAreaRef(SimpleRangePart part1, SimpleRangePart part2) {
if (!part1.isCompatibleForArea(part2)) {
throw new FormulaParseException("has incompatible parts: '"
+ part1.getRep() + "' and '" + part2.getRep() + "'.");
}
if (part1.isRow()) {
return AreaReference.getWholeRow(part1.getRep(), part2.getRep());
}
if (part1.isColumn()) {
return AreaReference.getWholeColumn(part1.getRep(), part2.getRep());
}
return new AreaReference(part1.getCellReference(), part2.getCellReference());
}
/**
* Matches a zero or one letter-runs followed by zero or one digit-runs.
* Either or both runs man optionally be prefixed with a single '$'.
* (copied+modified from {@link org.apache.poi.ss.util.CellReference#CELL_REF_PATTERN})
*/
private static final Pattern CELL_REF_PATTERN = Pattern.compile("(\\$?[A-Za-z]+)?(\\$?[0-9]+)?");
/**
* Parses out a potential LHS or RHS of a ':' intended to produce a plain AreaRef. Normally these are
* proper cell references but they could also be row or column refs like "$AC" or "10"
* @return <code>null</code> (and leaves {@link #_pointer} unchanged if a proper range part does not parse out
*/
private SimpleRangePart parseSimpleRangePart() {
int ptr = _pointer-1; // TODO avoid StringIndexOutOfBounds
boolean hasDigits = false;
boolean hasLetters = false;
while (ptr < _formulaLength) {
char ch = _formulaString.charAt(ptr);
if (Character.isDigit(ch)) {
hasDigits = true;
} else if (Character.isLetter(ch)) {
hasLetters = true;
} else if (ch =='$') {
//
} else {
break;
}
ptr++;
}
if (ptr <= _pointer-1) {
return null;
}
String rep = _formulaString.substring(_pointer-1, ptr);
if (!CELL_REF_PATTERN.matcher(rep).matches()) {
return null;
}
// Check range bounds against grid max
if (hasLetters && hasDigits) {
if (!isValidCellReference(rep)) {
return null;
}
} else if (hasLetters) {
if (!CellReference.isColumnWithnRange(rep.replace("$", ""))) {
return null;
}
} else if (hasDigits) {
int i;
try {
i = Integer.parseInt(rep.replace("$", ""));
} catch (NumberFormatException e) {
return null;
}
if (i<1 || i>65536) {
return null;
}
} else {
// just dollars ? can this happen?
return null;
}
resetPointer(ptr+1); // stepping forward
return new SimpleRangePart(rep, hasLetters, hasDigits);
}
/**
* A1, $A1, A$1, $A$1, A, 1
*/
private static final class SimpleRangePart {
private enum Type {
CELL, ROW, COLUMN;
public static Type get(boolean hasLetters, boolean hasDigits) {
if (hasLetters) {
return hasDigits ? CELL : COLUMN;
}
if (!hasDigits) {
throw new IllegalArgumentException("must have either letters or numbers");
}
return ROW;
}
}
private final Type _type;
private final String _rep;
public SimpleRangePart(String rep, boolean hasLetters, boolean hasNumbers) {
_rep = rep;
_type = Type.get(hasLetters, hasNumbers);
}
public boolean isCell() {
return _type == Type.CELL;
}
public boolean isRowOrColumn() {
return _type != Type.CELL;
}
public CellReference getCellReference() {
if (_type != Type.CELL) {
throw new IllegalStateException("Not applicable to this type");
}
return new CellReference(_rep);
}
public boolean isColumn() {
return _type == Type.COLUMN;
}
public boolean isRow() {
return _type == Type.ROW;
}
public String getRep() {
return _rep;
}
/**
* @return <code>true</code> if the two range parts can be combined in an
* {@link AreaPtg} ( Note - the explicit range operator (:) may still be valid
* when this method returns <code>false</code> )
*/
public boolean isCompatibleForArea(SimpleRangePart part2) {
return _type == part2._type;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(64);
sb.append(getClass().getName()).append(" [");
sb.append(_rep);
sb.append("]");
return sb.toString();
}
}
/**
* Note - caller should reset {@link #_pointer} upon <code>null</code> result
* @param iden identifier prefix (if unquoted, it is terminated at first dot)
* @return The sheet name as an identifier <code>null</code> if '!' is not found in the right place
*/
private SheetIdentifier parseSheetName() {
String bookName;
if (look == '[') {
StringBuilder sb = new StringBuilder();
GetChar();
while (look != ']') {
sb.append(look);
GetChar();
}
GetChar();
bookName = sb.toString();
} else {
bookName = null;
}
if (look == '\'') {
StringBuffer sb = new StringBuffer();
Match('\'');
boolean done = look == '\'';
while(!done) {
sb.append(look);
GetChar();
if(look == '\'')
{
Match('\'');
done = look != '\'';
}
}
Identifier iden = new Identifier(sb.toString(), true);
// quoted identifier - can't concatenate anything more
SkipWhite();
if (look == '!') {
GetChar();
return new SheetIdentifier(bookName, iden);
}
return null;
}
// unquoted sheet names must start with underscore or a letter
if (look =='_' || Character.isLetter(look)) {
StringBuilder sb = new StringBuilder();
// can concatenate idens with dots
while (isUnquotedSheetNameChar(look)) {
sb.append(look);
GetChar();
}
SkipWhite();
if (look == '!') {
GetChar();
return new SheetIdentifier(bookName, new Identifier(sb.toString(), false));
}
return null;
}
return null;
}
/**
* very similar to {@link SheetNameFormatter#isSpecialChar(char)}
*/
private static boolean isUnquotedSheetNameChar(char ch) {
if(Character.isLetterOrDigit(ch)) {
return true;
}
switch(ch) {
case '.': // dot is OK
case '_': // underscore is OK
return true;
}
return false;
}
/**
* @return <code>true</code> if the specified name is a valid cell reference
*/
private static boolean isValidCellReference(String str) {
return CellReference.classifyCellReference(str) == NameType.CELL;
}
/**
* Note - Excel function names are 'case aware but not case sensitive'. This method may end
* up creating a defined name record in the workbook if the specified name is not an internal
* Excel function, and has not been encountered before.
*
* @param name case preserved function name (as it was entered/appeared in the formula).
*/
private ParseNode function(String name) {
Ptg nameToken = null;
if(!AbstractFunctionPtg.isBuiltInFunctionName(name)) {
// user defined function
// in the token tree, the name is more or less the first argument
if (_book == null) {
// Only test cases omit the book (expecting it not to be needed)
throw new IllegalStateException("Need book to evaluate name '" + name + "'");
}
EvaluationName hName = _book.getName(name, _sheetIndex);
if (hName == null) {
nameToken = _book.getNameXPtg(name);
if (nameToken == null) {
throw new FormulaParseException("Name '" + name
+ "' is completely unknown in the current workbook");
}
} else {
if (!hName.isFunctionName()) {
throw new FormulaParseException("Attempt to use name '" + name
+ "' as a function, but defined name in workbook does not refer to a function");
}
// calls to user-defined functions within the workbook
// get a Name token which points to a defined name record
nameToken = hName.createPtg();
}
}
Match('(');
ParseNode[] args = Arguments();
Match(')');
return getFunction(name, nameToken, args);
}
/**
* Generates the variable function ptg for the formula.
* <p>
* For IF Formulas, additional PTGs are added to the tokens
* @param name a {@link NamePtg} or {@link NameXPtg} or <code>null</code>
* @param numArgs
* @return Ptg a null is returned if we're in an IF formula, it needs extreme manipulation and is handled in this function
*/
private ParseNode getFunction(String name, Ptg namePtg, ParseNode[] args) {
FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByName(name.toUpperCase());
int numArgs = args.length;
if(fm == null) {
if (namePtg == null) {
throw new IllegalStateException("NamePtg must be supplied for external functions");
}
// must be external function
ParseNode[] allArgs = new ParseNode[numArgs+1];
allArgs[0] = new ParseNode(namePtg);
System.arraycopy(args, 0, allArgs, 1, numArgs);
return new ParseNode(new FuncVarPtg(name, (byte)(numArgs+1)), allArgs);
}
if (namePtg != null) {
throw new IllegalStateException("NamePtg no applicable to internal functions");
}
boolean isVarArgs = !fm.hasFixedArgsLength();
int funcIx = fm.getIndex();
if (funcIx == FunctionMetadataRegistry.FUNCTION_INDEX_SUM && args.length == 1) {
// Excel encodes the sum of a single argument as tAttrSum
// POI does the same for consistency, but this is not critical
return new ParseNode(AttrPtg.getSumSingle(), args);
// The code below would encode tFuncVar(SUM) which seems to do no harm
}
validateNumArgs(args.length, fm);
AbstractFunctionPtg retval;
if(isVarArgs) {
retval = new FuncVarPtg(name, (byte)numArgs);
} else {
retval = new FuncPtg(funcIx);
}
return new ParseNode(retval, args);
}
private void validateNumArgs(int numArgs, FunctionMetadata fm) {
if(numArgs < fm.getMinParams()) {
String msg = "Too few arguments to function '" + fm.getName() + "'. ";
if(fm.hasFixedArgsLength()) {
msg += "Expected " + fm.getMinParams();
} else {
msg += "At least " + fm.getMinParams() + " were expected";
}
msg += " but got " + numArgs + ".";
throw new FormulaParseException(msg);
}
//the maximum number of arguments depends on the Excel version
int maxArgs;
if (fm.hasUnlimitedVarags()) {
if(_book != null) {
maxArgs = _book.getSpreadsheetVersion().getMaxFunctionArgs();
} else {
//_book can be omitted by test cases
maxArgs = fm.getMaxParams(); // just use BIFF8
}
} else {
maxArgs = fm.getMaxParams();
}
if(numArgs > maxArgs) {
String msg = "Too many arguments to function '" + fm.getName() + "'. ";
if(fm.hasFixedArgsLength()) {
msg += "Expected " + maxArgs;
} else {
msg += "At most " + maxArgs + " were expected";
}
msg += " but got " + numArgs + ".";
throw new FormulaParseException(msg);
}
}
private static boolean isArgumentDelimiter(char ch) {
return ch == ',' || ch == ')';
}
/** get arguments to a function */
private ParseNode[] Arguments() {
//average 2 args per function
List<ParseNode> temp = new ArrayList<ParseNode>(2);
SkipWhite();
if(look == ')') {
return ParseNode.EMPTY_ARRAY;
}
boolean missedPrevArg = true;
int numArgs = 0;
while (true) {
SkipWhite();
if (isArgumentDelimiter(look)) {
if (missedPrevArg) {
temp.add(new ParseNode(MissingArgPtg.instance));
numArgs++;
}
if (look == ')') {
break;
}
Match(',');
missedPrevArg = true;
continue;
}
temp.add(comparisonExpression());
numArgs++;
missedPrevArg = false;
SkipWhite();
if (!isArgumentDelimiter(look)) {
throw expected("',' or ')'");
}
}
ParseNode[] result = new ParseNode[temp.size()];
temp.toArray(result);
return result;
}
/** Parse and Translate a Math Factor */
private ParseNode powerFactor() {
ParseNode result = percentFactor();
while(true) {
SkipWhite();
if(look != '^') {
return result;
}
Match('^');
ParseNode other = percentFactor();
result = new ParseNode(PowerPtg.instance, result, other);
}
}
private ParseNode percentFactor() {
ParseNode result = parseSimpleFactor();
while(true) {
SkipWhite();
if(look != '%') {
return result;
}
Match('%');
result = new ParseNode(PercentPtg.instance, result);
}
}
/**
* factors (without ^ or % )
*/
private ParseNode parseSimpleFactor() {
SkipWhite();
switch(look) {
case '#':
return new ParseNode(ErrPtg.valueOf(parseErrorLiteral()));
case '-':
Match('-');
return new ParseNode(UnaryMinusPtg.instance, powerFactor());
case '+':
Match('+');
return new ParseNode(UnaryPlusPtg.instance, powerFactor());
case '(':
Match('(');
ParseNode inside = comparisonExpression();
Match(')');
return new ParseNode(ParenthesisPtg.instance, inside);
case '"':
return new ParseNode(new StringPtg(parseStringLiteral()));
case '{':
Match('{');
ParseNode arrayNode = parseArray();
Match('}');
return arrayNode;
}
if (IsAlpha(look) || Character.isDigit(look) || look == '\'' || look == '['){
return parseRangeExpression();
}
if (look == '.') {
return new ParseNode(parseNumber());
}
throw expected("cell ref or constant literal");
}
private ParseNode parseArray() {
List<Object[]> rowsData = new ArrayList<Object[]>();
while(true) {
Object[] singleRowData = parseArrayRow();
rowsData.add(singleRowData);
if (look == '}') {
break;
}
if (look != ';') {
throw expected("'}' or ';'");
}
Match(';');
}
int nRows = rowsData.size();
Object[][] values2d = new Object[nRows][];
rowsData.toArray(values2d);
int nColumns = values2d[0].length;
checkRowLengths(values2d, nColumns);
return new ParseNode(new ArrayPtg(values2d));
}
private void checkRowLengths(Object[][] values2d, int nColumns) {
for (int i = 0; i < values2d.length; i++) {
int rowLen = values2d[i].length;
if (rowLen != nColumns) {
throw new FormulaParseException("Array row " + i + " has length " + rowLen
+ " but row 0 has length " + nColumns);
}
}
}
private Object[] parseArrayRow() {
List<Object> temp = new ArrayList<Object>();
while (true) {
temp.add(parseArrayItem());
SkipWhite();
switch(look) {
case '}':
case ';':
break;
case ',':
Match(',');
continue;
default:
throw expected("'}' or ','");
}
break;
}
Object[] result = new Object[temp.size()];
temp.toArray(result);
return result;
}
private Object parseArrayItem() {
SkipWhite();
switch(look) {
case '"': return new UnicodeString(parseStringLiteral());
case '#': return ErrorConstant.valueOf(parseErrorLiteral());
case 'F': case 'f':
case 'T': case 't':
return parseBooleanLiteral();
}
// else assume number
return convertArrayNumber(parseNumber());
}
private Boolean parseBooleanLiteral() {
String iden = parseUnquotedIdentifier();
if ("TRUE".equalsIgnoreCase(iden)) {
return Boolean.TRUE;
}
if ("FALSE".equalsIgnoreCase(iden)) {
return Boolean.FALSE;
}
throw expected("'TRUE' or 'FALSE'");
}
private static Double convertArrayNumber(Ptg ptg) {
if (ptg instanceof IntPtg) {
return new Double(((IntPtg)ptg).getValue());
}
if (ptg instanceof NumberPtg) {
return new Double(((NumberPtg)ptg).getValue());
}
throw new RuntimeException("Unexpected ptg (" + ptg.getClass().getName() + ")");
}
private Ptg parseNumber() {
String number2 = null;
String exponent = null;
String number1 = GetNum();
if (look == '.') {
GetChar();
number2 = GetNum();
}
if (look == 'E') {
GetChar();
String sign = "";
if (look == '+') {
GetChar();
} else if (look == '-') {
GetChar();
sign = "-";
}
String number = GetNum();
if (number == null) {
throw expected("Integer");
}
exponent = sign + number;
}
if (number1 == null && number2 == null) {
throw expected("Integer");
}
return getNumberPtgFromString(number1, number2, exponent);
}
private int parseErrorLiteral() {
Match('#');
String part1 = parseUnquotedIdentifier().toUpperCase();
if (part1 == null) {
throw expected("remainder of error constant literal");
}
switch(part1.charAt(0)) {
case 'V':
if(part1.equals("VALUE")) {
Match('!');
return HSSFErrorConstants.ERROR_VALUE;
}
throw expected("#VALUE!");
case 'R':
if(part1.equals("REF")) {
Match('!');
return HSSFErrorConstants.ERROR_REF;
}
throw expected("#REF!");
case 'D':
if(part1.equals("DIV")) {
Match('/');
Match('0');
Match('!');
return HSSFErrorConstants.ERROR_DIV_0;
}
throw expected("#DIV/0!");
case 'N':
if(part1.equals("NAME")) {
Match('?'); // only one that ends in '?'
return HSSFErrorConstants.ERROR_NAME;
}
if(part1.equals("NUM")) {
Match('!');
return HSSFErrorConstants.ERROR_NUM;
}
if(part1.equals("NULL")) {
Match('!');
return HSSFErrorConstants.ERROR_NULL;
}
if(part1.equals("N")) {
Match('/');
if(look != 'A' && look != 'a') {
throw expected("#N/A");
}
Match(look);
// Note - no '!' or '?' suffix
return HSSFErrorConstants.ERROR_NA;
}
throw expected("#NAME?, #NUM!, #NULL! or #N/A");
}
throw expected("#VALUE!, #REF!, #DIV/0!, #NAME?, #NUM!, #NULL! or #N/A");
}
private String parseUnquotedIdentifier() {
if (look == '\'') {
throw expected("unquoted identifier");
}
StringBuilder sb = new StringBuilder();
while (Character.isLetterOrDigit(look) || look == '.') {
sb.append(look);
GetChar();
}
if (sb.length() < 1) {
return null;
}
return sb.toString();
}
/**
* Get a PTG for an integer from its string representation.
* return Int or Number Ptg based on size of input
*/
private static Ptg getNumberPtgFromString(String number1, String number2, String exponent) {
StringBuffer number = new StringBuffer();
if (number2 == null) {
number.append(number1);
if (exponent != null) {
number.append('E');
number.append(exponent);
}
String numberStr = number.toString();
int intVal;
try {
intVal = Integer.parseInt(numberStr);
} catch (NumberFormatException e) {
return new NumberPtg(numberStr);
}
if (IntPtg.isInRange(intVal)) {
return new IntPtg(intVal);
}
return new NumberPtg(numberStr);
}
if (number1 != null) {
number.append(number1);
}
number.append('.');
number.append(number2);
if (exponent != null) {
number.append('E');
number.append(exponent);
}
return new NumberPtg(number.toString());
}
private String parseStringLiteral() {
Match('"');
StringBuffer token = new StringBuffer();
while (true) {
if (look == '"') {
GetChar();
if (look != '"') {
break;
}
}
token.append(look);
GetChar();
}
return token.toString();
}
/** Parse and Translate a Math Term */
private ParseNode Term() {
ParseNode result = powerFactor();
while(true) {
SkipWhite();
Ptg operator;
switch(look) {
case '*':
Match('*');
operator = MultiplyPtg.instance;
break;
case '/':
Match('/');
operator = DividePtg.instance;
break;
default:
return result; // finished with Term
}
ParseNode other = powerFactor();
result = new ParseNode(operator, result, other);
}
}
private ParseNode unionExpression() {
ParseNode result = comparisonExpression();
boolean hasUnions = false;
while (true) {
SkipWhite();
switch(look) {
case ',':
GetChar();
hasUnions = true;
ParseNode other = comparisonExpression();
result = new ParseNode(UnionPtg.instance, result, other);
continue;
}
if (hasUnions) {
return augmentWithMemPtg(result);
}
return result;
}
}
private ParseNode comparisonExpression() {
ParseNode result = concatExpression();
while (true) {
SkipWhite();
switch(look) {
case '=':
case '>':
case '<':
Ptg comparisonToken = getComparisonToken();
ParseNode other = concatExpression();
result = new ParseNode(comparisonToken, result, other);
continue;
}
return result; // finished with predicate expression
}
}
private Ptg getComparisonToken() {
if(look == '=') {
Match(look);
return EqualPtg.instance;
}
boolean isGreater = look == '>';
Match(look);
if(isGreater) {
if(look == '=') {
Match('=');
return GreaterEqualPtg.instance;
}
return GreaterThanPtg.instance;
}
switch(look) {
case '=':
Match('=');
return LessEqualPtg.instance;
case '>':
Match('>');
return NotEqualPtg.instance;
}
return LessThanPtg.instance;
}
private ParseNode concatExpression() {
ParseNode result = additiveExpression();
while (true) {
SkipWhite();
if(look != '&') {
break; // finished with concat expression
}
Match('&');
ParseNode other = additiveExpression();
result = new ParseNode(ConcatPtg.instance, result, other);
}
return result;
}
/** Parse and Translate an Expression */
private ParseNode additiveExpression() {
ParseNode result = Term();
while (true) {
SkipWhite();
Ptg operator;
switch(look) {
case '+':
Match('+');
operator = AddPtg.instance;
break;
case '-':
Match('-');
operator = SubtractPtg.instance;
break;
default:
return result; // finished with additive expression
}
ParseNode other = Term();
result = new ParseNode(operator, result, other);
}
}
//{--------------------------------------------------------------}
//{ Parse and Translate an Assignment Statement }
/**
procedure Assignment;
var Name: string[8];
begin
Name := GetName;
Match('=');
Expression;
end;
**/
/**
* API call to execute the parsing of the formula
*
*/
private void parse() {
_pointer=0;
GetChar();
_rootNode = unionExpression();
if(_pointer <= _formulaLength) {
String msg = "Unused input [" + _formulaString.substring(_pointer-1)
+ "] after attempting to parse the formula [" + _formulaString + "]";
throw new FormulaParseException(msg);
}
}
private Ptg[] getRPNPtg(int formulaType) {
OperandClassTransformer oct = new OperandClassTransformer(formulaType);
// RVA is for 'operand class': 'reference', 'value', 'array'
oct.transformFormula(_rootNode);
return ParseNode.toTokenArray(_rootNode);
}
Merged revisions 627779-634630 via svnmerge from https://svn.apache.org/repos/asf/poi/trunk ........ r627779 | nick | 2008-02-14 16:32:49 +0100 (Thu, 14 Feb 2008) | 1 line In the interests of sanity, stop having hssf test data files in scratchpad and main, go to just having them in main ........ r627788 | nick | 2008-02-14 17:01:10 +0100 (Thu, 14 Feb 2008) | 1 line Big formula update from Josh from bug #44364 - support for Match, NA and SumProduct functions, and initial error support in functions ........ r627999 | nick | 2008-02-15 11:30:10 +0100 (Fri, 15 Feb 2008) | 1 line To avoid confusion and repeated changes in svn, update the TestDataValidation test to output its file (that needs opening in excel to check to output) into the system tmp directory ........ r628027 | nick | 2008-02-15 12:45:13 +0100 (Fri, 15 Feb 2008) | 1 line Fix for bug #44403 - Have mid use the third argument properly, and test ........ r628029 | nick | 2008-02-15 12:53:25 +0100 (Fri, 15 Feb 2008) | 1 line Fix for bug #44413 from Josh - Fix for circular references in INDEX, OFFSET, VLOOKUP formulas, where a cell is actually allowed to reference itself ........ r628033 | nick | 2008-02-15 13:04:42 +0100 (Fri, 15 Feb 2008) | 1 line Fix from Josh from bug #44417 - Improved handling of references for the need to quote the sheet name for some formulas, but not when fetching a sheet by name ........ r628035 | nick | 2008-02-15 13:13:25 +0100 (Fri, 15 Feb 2008) | 1 line Fix from Josh from bug #44421 - Update Match function to properly support Area references ........ r628044 | nick | 2008-02-15 13:59:40 +0100 (Fri, 15 Feb 2008) | 1 line Partial fix for bug #44410 - support whole column ranges such as C:C in the formula evaluator (so SUM(D:D) will now work). However, the formula string will still be displayed wrong ........ r628065 | nick | 2008-02-15 14:50:38 +0100 (Fri, 15 Feb 2008) | 1 line Further support for whole-column references, including formula strings and the evaluator. Also has some new tests for it ........ r628714 | nick | 2008-02-18 14:08:16 +0100 (Mon, 18 Feb 2008) | 1 line Update notice for latest guidance on ooxml xsd licence, and update getting involved to link to the newly released binary file format docs ........ r629552 | nick | 2008-02-20 19:14:30 +0100 (Wed, 20 Feb 2008) | 1 line Patch from Josh from bug #44403 - Further support for unusual, but valid, arguments to the Mid function ........ r629738 | nick | 2008-02-21 11:36:08 +0100 (Thu, 21 Feb 2008) | 1 line Fix from Josh from bug #44456 - Update contrib SViewer to not fail if a HSSFRow is null ........ r629742 | nick | 2008-02-21 11:49:25 +0100 (Thu, 21 Feb 2008) | 1 line Use the right way to figure out how many rows on a sheet, so we display the row number for all of them on the left hand side. Also, tidy up some imports ........ r629755 | nick | 2008-02-21 12:34:25 +0100 (Thu, 21 Feb 2008) | 1 line Fix bug 38921, where HSSFPalette.findSimilar() wasn't working properly, and add tests for it ........ r629821 | nick | 2008-02-21 16:08:44 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44371 - support for OFFSET function, and various tweaks to the formula evaluator to support this ........ r629829 | nick | 2008-02-21 16:35:59 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44366 - InputStreams passed to POIFSFileSystem are now automatically closed. A warning is generated for people who might've relied on them not being closed before, and a wrapper to restore the old behaviour is supplied ........ r629831 | nick | 2008-02-21 16:40:34 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44437 - improved unit test for poifs ........ r629832 | nick | 2008-02-21 16:42:06 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44437 - improved unit test for poifs ........ r629837 | nick | 2008-02-21 16:48:52 +0100 (Thu, 21 Feb 2008) | 1 line Patch from Josh from bug #44449 - Handle SharedFormulas better, for where there are formulas for the same area on two sheets, and when the shared formula flag is set incorrectly ........ r629849 | nick | 2008-02-21 17:22:18 +0100 (Thu, 21 Feb 2008) | 1 line Add a disabled test for a file with whacky StyleRecords that trigger an AIOOB ........ r629865 | nick | 2008-02-21 17:44:46 +0100 (Thu, 21 Feb 2008) | 1 line At the request of legal-discuss, shuffle the ooxml xsd licence details into LICENSE from NOTICE ........ r630160 | nick | 2008-02-22 12:23:50 +0100 (Fri, 22 Feb 2008) | 1 line Patch from Josh from bug #44450 - VLookup and HLookup support, and improvements to Lookup and Offset ........ r630164 | nick | 2008-02-22 12:40:00 +0100 (Fri, 22 Feb 2008) | 1 line Bug #44471 - Crystal Reports generates files with short StyleRecords, which isn't allowed in the spec. Work around this ........ r633114 | nick | 2008-03-03 16:01:18 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Paolo from bug #44481 - getVerticallyCenter shouldn't take a parameter, but leave the old version in as deprecated for now ........ r633118 | nick | 2008-03-03 16:10:46 +0100 (Mon, 03 Mar 2008) | 1 line Fix from Yegor from bug #44491 - don't have the new style handy POIDocument property stuff break old style hpsf+hssf use ........ r633126 | nick | 2008-03-03 16:26:38 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Josh from bug #44495 - Handle named cell ranges in formulas that have lower case parts ........ r633151 | nick | 2008-03-03 17:09:02 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Josh from bug #44510 - Fix how DVALRecord works with dropdowns ........ r633169 | nick | 2008-03-03 17:55:00 +0100 (Mon, 03 Mar 2008) | 1 line Patch from Josh from bug #44508 - Fix formula evaluation with evaluateInCell on boolean formulas ........ r633205 | nick | 2008-03-03 18:47:36 +0100 (Mon, 03 Mar 2008) | 1 line Fix indent, add more documentation, and make the error message more helpful ........ r633505 | nick | 2008-03-04 16:06:29 +0100 (Tue, 04 Mar 2008) | 1 line Problem files from bug #44501 ........ r633547 | nick | 2008-03-04 17:53:32 +0100 (Tue, 04 Mar 2008) | 1 line Big patch from Josh from bug #44504 - lots of formula parser improvements ........ r633548 | nick | 2008-03-04 17:59:02 +0100 (Tue, 04 Mar 2008) | 1 line Changelog update for last patch ........ r634318 | nick | 2008-03-06 16:54:06 +0100 (Thu, 06 Mar 2008) | 1 line Change the behaviour on short last blocks to be a warning not an exception, as some people seem to have "real" valid files that trigger this. Fixed bug #28231 ........ r634371 | nick | 2008-03-06 19:06:48 +0100 (Thu, 06 Mar 2008) | 1 line Embeded files from bug #44524 ........ r634372 | nick | 2008-03-06 19:13:47 +0100 (Thu, 06 Mar 2008) | 1 line Add broken test for bug #43901 ........ r634617 | nick | 2008-03-07 12:18:02 +0100 (Fri, 07 Mar 2008) | 1 line Patch from Josh from bug #43901 - Correctly update the internal last cell number when adding and removing cells (previously sometimes off-by-one) ........ r634619 | nick | 2008-03-07 12:36:14 +0100 (Fri, 07 Mar 2008) | 1 line Improved support for read-only recommended workbooks, fixing bug #44536 ........ r634630 | nick | 2008-03-07 13:06:18 +0100 (Fri, 07 Mar 2008) | 1 line Patch largely from Josh from bug #44539 - Support for area references in formulas of rows >= 32768 ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@634936 13f79535-47bb-0310-9956-ffa450edef68
2008-03-08 06:49:00 -05:00
}