You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2003/07/28 05:42:41 UTC

DO NOT REPLY [Bug 21923] New: - [PATCH] Modify HSSFWorkbook, FormulaParser and SheetReferences to support 3DRefs

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21923>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21923

[PATCH] Modify HSSFWorkbook, FormulaParser and SheetReferences to support 3DRefs

           Summary: [PATCH] Modify HSSFWorkbook, FormulaParser and
                    SheetReferences to support 3DRefs
           Product: POI
           Version: 2.0-pre3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: eladner@goldinc.com


This patch modifies HSSFWorkbook, FormulaParser and SheetReferences to allow
sheet references to be captured from HSSFWorkbook (new method
getSheetReferences, which mirrors Workbook.getSheetReferences()) and passed into
the FormulaParser (new methods getSheetReferences() and setSheetReferences()). 
I purposefully didn't add a new constructor for FormulaParser(String,
SheetReferences) because of the common practice up to now of just calling 'new
FormulaParser(formula, null)' (null for the workbook).  That call produces an
ambiguous call error.  Instead I added the setSheetReferences, so the typical
way to call it now would be something like:

        POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file));
        HSSFWorkbook wb    = new HSSFWorkbook(fs);
        HSSFSheet sheet    = wb.getSheetAt(0);
        HSSFRow row        = sheet.getRow(0);
        SheetReferneces refs = wb.getSheetReferences();

        FormulaParser fp = new FormulaParser(formula, null);
        fp.setSheetReferences(refs);
        fp.parse();

Also, modifications to FormulaParser were required to check whether to get the
sheet numbers from the workbook, if valid, or the sheet references, if supplied.
 This also required a new method getSheetIndex() in SheetReferences (the
counterpart to getSheetName()).

A unit test was added to TestSheetReferences to test the reverse lookups.

Unit tests weren't added yet to test the advanced formula parsing, as I'm not
that up on JUnit yet, but if anyone has an pointers, I'm all ears.