poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clauss, Arne" <Arne.Cla...@gedas.de>
Subject AW: How to modify cells using the named range
Date Wed, 02 Apr 2003 15:07:55 GMT
Hello!

Thanks for the reply!

I tried the following code using poi 1.10.0dev:

HSSFName myName = wb.getNameAt(wb.getNameIndex("Test"));
cat.debug("HSSFName=" + myName.toString());
String ref = myName.getReference();
cat.debug("String of reference=" + ref);
AreaReference myAreaReference = new AreaReference(ref);
CellReference[] myCellReference = myAreaReference.getCells();
HSSFSheet mySheet = wb.getSheetAt(0);
cat.debug("Length of CellReference=" + myCellReference.length);
HSSFRow myRow = mySheet.getRow(myCellReference[0].getRow());
HSSFCell myCell = myRow.getCell((short) myCellReference[0].getCol());
myCell.setCellValue("Test");

When the program executes I get the following output:

HSSFName=org.apache.poi.hssf.usermodel.HSSFName@7169a36c
String of reference=Tabelle1!$B$5

and an Exception occurs getting the AreaReference:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1

I think the reference String looks quite nice. Where's the fault?

Any help is welcome!

Regards,

Arne

> -----Ursprüngliche Nachricht-----
> Von: Danny Mui [mailto:danny@muibros.com] 
> Gesendet: Dienstag, 25. März 2003 19:04
> An: POI Users List
> Betreff: Re: How to modify cells using the named range
> 
> 
> That method simply gives you a HSSFName object that gives you the 
> formula-based reference (i.e Sheet1!A2:A5).
> 
> You can use:
> 
> http://jakarta.apache.org/poi/javadocs/org/apache/poi/hssf/uti
> l/AreaReference.html
> 
> |AreaReference ref = new AreaReference (name.getReference());
> 
> That will get you your cell indices, albeit the long way.  Maybe this 
> should be easier?
> 
> danny
> |
> 
> Clauss, Arne wrote:
> 
> >Hello!
> >
> >I would like to modify an excel-file in an web-application. 
> Because the 
> >design of the excel-file could be changed I would like to 
> use the named 
> >ranges for putting the information into the excel-file. I 
> think, that 
> >this make me independent of design changes (adding new rows an 
> >columns).
> >
> >I just want to get a cell for modifying it by the using the 
> named range 
> >of the cell to find it.
> >
> >I have found in the class "HSSFWorkbook" the method "getNameIndex". 
> >What should I do with the returned index. I haven't found a 
> method for 
> >getting a HSSFCell with the returned index.
> >
> >Any help is appreciated.
> >
> >Kind regards,
> >
> >Arne
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: poi-user-help@jakarta.apache.org
> >
> >  
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
> 

Mime
View raw message