Bug 47056 - FormulaParser doesn't work correctly for sheets names which contains white spaces.
Summary: FormulaParser doesn't work correctly for sheets names which contains white sp...
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.5-dev
Hardware: PC Windows XP
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-20 05:31 UTC by Natalia.Yastrebova
Modified: 2009-04-20 09:41 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Natalia.Yastrebova 2009-04-20 05:31:18 UTC
Class Poi.SS.Formula.FormulaParser.java,  function  private Identifier parseIdentifier() doesn't work properly for parsing NameRanges included Sheet Names which contains more than one word. 
For example:
We have next NamedRanges: "Workunits!$A$1:$B$5" and "Workunit status!$A$1:$C$2".
For second reference we get exception FormulaParseException("Specified named range Workunit does not exist in the current workbook."
which comes from this method: private Ptg parseNameOrCellRef(Identifier iden) 

        EvaluationName evalName = _book.getName(name, _sheetIndex);
        if (evalName == null) {
            throw new FormulaParseException("Specified named range '"
            + name + "' does not exist in the current workbook.");
        }

It happens because parseIdentifier() returns only first part of Sheet name until first white space.
Comment 1 Yegor Kozlov 2009-04-20 09:41:17 UTC
POI requires sheet names with special characters  (space, !, etc) to be
delimited in single quotes. The following code works fine to me:

        Workbook source = new HSSFWorkbook();
        Sheet sheet = source.createSheet("Workunit status");
        Name nm = source.createName();
        nm.setNameName("name1");
        nm.setRefersToFormula("'Workunit status'!$A$1:$C$2");


Regards,
Yegor