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>(ReferencePtg.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(FormulaParser.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/usermodel/HSSFWork

book.html#createName()
http://jakarta.apache.org/poi/apidocs/org/apache/poi/hssf/usermodel/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/

Reply via email to