You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Fasihullah Askiri <fa...@gmail.com> on 2005/02/07 16:55:52 UTC

Re: problem clone poi.hssf.CellStyle

Hi
As I understand, when u say currentCell.getCellStyle() the return
value u get is the same as u get from
mostOfTheOtherCells.getCellStyle()
When I say "is the same as" I dont mean they have the same data, but
that they point to the same memory location, you can check this by
doing
System.out.println(a.getCellStyle()==b.getCellStyle());
== operator as you will realise, does not compare the contents [as equals()]
but compares the memory location.

This technique is called Flyweight. I am not sure that this is the
case, but I guess it is.... as such, you can do little about it...
maybe you can raise an enhancement bug on POI requesting for clone
method.

Again I am not sure of the implementation. This was what I thought was
the problem


Thanx
Fasih

> "if I do cellStyle = workbook.createCellStyle(); its all works great,
> each cell maintains its format but obviously I lose the colours and
> font styles of the original cell (which I am trying to preserve). I
> can preserve the style if I do currentCell.getCellStyle() but I change
> the format of all styles (as indicated in thread). I've tried to call
> the .clone method but this has not been overridden and I see on
> compiliation
> 
> clone() has protected access in java.lang.Object
> And there appears to be no contructor for CellStyle that takes an
> existing Cellstyle and clones it :-(
> 
> so does anyone have a solution for this problem?, seems a common
> problem I'd imagine?"
> 
> have u got any solution for it, please reply asap
> thanks in advance
> 
> --
> bye
> kamal
> (Verizon, Chennai)
> Contact No: 09884339257
>

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