Hi,
 
Here I did some small Named Range Example
 
        POIFSFileSystem fs  = null;
        HSSFWorkbook wb     = null;
        try {
            fs = new POIFSFileSystem(new FileInputStream("c:\\1.xls"));
            wb = new HSSFWorkbook(fs);
        } catch (FileNotFoundException ex){
        } catch (IOException ex){
        }
       
        //Getting NAmed Range
        HSSFName namedRange1 = wb.getNameAt(0);
        //Getting it sheet name
        String sheetName = namedRange1.getSheetName();
        //Getting its reference
        String referece = namedRange1.getReference();
       
        //Creating new Named Range
        HSSFName newNamedRange = wb.createName();
       
        //Getting Sheet Name for the reference
        sheetName = wb.getSheetName(0);
       
        //Setting its name
        newNamedRange.setNameName("RangeTest");
        //Setting its reference
        newNamedRange.setReference(sheetName + ".$D$4:$E$8");
       
       
        try {
            FileOutputStream fileOut = new FileOutputStream("c:\\1.xls");
            wb.write(fileOut);
            fileOut.close();
        } catch (FileNotFoundException ex){
        } catch (IOException ex){
        }
 
 I hope its says it all :))
 
                                                        Libin Roman
----- Original Message -----
Sent: Wednesday, April 17, 2002 5:02 PM
Subject: Re: Named Ranges

Okay, I have applied that patch to my local copy.  Unfortunately the patches did not contain unit tests, documentation or examples so I'm adding those and it will not be available until that's finished.  Thanks for your work... looks good so far.
 
Regards,
 
Glen
 
----- Original Message -----
Sent: Tuesday, April 16, 2002 5:33 PM
Subject: Named Ranges

Hi ,
 
I have sent the Named Ranges patch to the bugzilla.
Hope to see it soon in the cvs :)))
 
From HSSFWorkbook you can create a new named range. From HSSFWork you can get the HSSFName (high level of named range) by name or by index , which from you get get the reference or to set it.
 
 
 
                                                    Hope you like it :)),
                                                        Libin Roman
 

Reply via email to