Bug 9632 - HSSFName getReference() error
Summary: HSSFName getReference() error
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2002-06-05 14:35 UTC by Iulian Mihai
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Iulian Mihai 2002-06-05 14:35:01 UTC
I hava created with Excel 2002 an empty workbook named input.xls
I hava defined a named range A1:D10 and I gave it the name NamedRangeName
After that I tried playing with that.
The problem is that HSSFName.getReference returns characters of the range like 
ASCII-1, in my case @1:C10 instead of A1:D10
I tried to write then to a file output.xls and if i opened it with Excel, the 
named range was corect,so I suppose there is no internal problem, maybe just 
in getReference() method.
I tested with the poi jar build 05.06.2002
Here is the source:

import junit.framework.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.*;

import org.apache.poi.hssf.usermodel.*;

public class TestNR
    public static void main(java.lang.String[] args) throws IOException
        FileInputStream fis = null;
        POIFSFileSystem fs  = null;
        HSSFWorkbook wb     = null;
        fis = new FileInputStream("input.xls");
        fs = new POIFSFileSystem(fis);
        wb = new HSSFWorkbook(fs);

		//Get index of the namedrange with the name 
= "NamedRangeName" , which was defined in input.xls as A1:D10
		int NamedRangeIndex	 = wb.getNameIndex("NamedRangeName");

		//Getting NAmed Range
        HSSFName namedRange1 = wb.getNameAt(NamedRangeIndex);

        //Getting its reference
        String reference = namedRange1.getReference();

		//Display reference

Comment 1 Danny Mui 2003-03-06 21:11:20 UTC
Fixed in the nightly as of 03/06/2003