Looks like you are using it correctly.

I thought initially that you were missing
something in 
   cellName.setCellFormula("PEGrossThrFam");
since it did not make a lot of sense as a 
formula to have just the named range, but 
turns out that is a valid formula :)

Apparently the Named Range in formulas 
is not yet supported...

~ amol



> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 12, 2005 9:39 AM
> To: POI Users List
> Subject: RE: How to define a name for a cell
> 
> 
> Amol,
> Can you send a sample of creating HSSFName. I'm trying to use 
> like this:
> HSSFName newName = wb.createName();
> newName.setNameName("PEGrossThrFam");
> newName.setReference("DataSheetFamily!$B$3:$B$3");
> HSSFCell cellName = rowname.createCell(( short ) 9);
> cellName.setCellStyle(cellOrg.getCellStyle());
> cellName.setCellType(HSSFCell.CELL_TYPE_FORMULA);
> cellName.setCellFormula("PEGrossThrFam");
> 
> and getting the following exception:
> 
> java.lang.StringIndexOutOfBoundsException: String index out 
> of range: 0
>       at java.lang.String.charAt(String.java:444)
>       at
> org.apache.poi.hssf.util.CellReference.<init>(CellReference.java:44)
>       at
> org.apache.poi.hssf.record.formula.ReferencePtg.<init>(Referen
> cePtg.java:50)
>       at
> org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:292)
>       at
> org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:480)
>       at
> org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:569)
>       at
> org.apache.poi.hssf.model.FormulaParser.Expression(FormulaPars
> er.java:617)
>       at
> org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:721)
>       at
> org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula(HSSFCell
> .java:669)
>       at HSSFTest.main(HSSFTest.java:390) - this is 
> setCellFormula line
> number
> 
> Thanks a lot,
> Michael D
> 
> 
> 
>                                                               
>                                                               
>            
>                       Amol Deshmukh                           
>                                                               
>            
>                       <[EMAIL PROTECTED]        To:       
> "'POI Users List'" <[email protected]>              
>                 
>                       s-us.com>                cc:            
>                                                               
>            
>                                                Subject:  RE: 
> How to define a name for a cell                               
            
>                       08/12/2005 08:13                        
>                                                               
>            
>                       AM                                      
>                                                               
>            
>                       Please respond to                       
>                                                               
>            
>                       "POI Users List"                        
>                                                               
>            
>                                                               
>                                                               
>            
>                                                               
>                                                               
>            
> 
> 
> 
> 
> Gerhard,
> 
> These should help:
> 
> http://jakarta.apache.org/poi/apidocs/org/apache/poi/hssf/user
> model/HSSFWork
> 
> book.html#createName()
> http://jakarta.apache.org/poi/apidocs/org/apache/poi/hssf/user
> model/HSSFName
> 
> .html
> 
> 
> Regards,
> ~ amol
> 
> 
> > -----Original Message-----
> > From: news [mailto:[EMAIL PROTECTED] Behalf Of Gerhard Hiller
> > Sent: Thursday, August 11, 2005 11:47 AM
> > To: [email protected]
> > Subject: How to define a name for a cell
> >
> >
> > Hi everybody,
> >
> > in Excel it is possible to define a name for a selection
> > (German Excel it is "Einfügen - Name - Definieren"),
> > in english one it should be something like
> > "Insert - name - define".
> >
> > Is it possible to do this with hssf-User-Model or somehow
> > else? I want to reference some columns in other sheets without
> > having to know the exact place of them. This could be done with
> > defining the name and then use it in other formulas.
> >
> > Thanks in advance,
> >
> > Gerhard Hiller
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> > The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to