Hi Curtis,

Yes... the problem here is that each column has it's own data format. The
data format is also specified in the style so you end up with (2 * number of
columns) styles. I still think that a better approach would be to have the
"clone()" method implemented.

----- Original Message ----- 
From: "Ling, Curtis" <[EMAIL PROTECTED]>
To: "'POI Users List'" <[EMAIL PROTECTED]>
Sent: Tuesday, May 11, 2004 12:21 PM
Subject: RE: Question about Cell Styles in Excell


> I'm still pretty new at HSSF, so this might be a dumb suggestion, but
isn't
> it possible to define only three styles (one for the header row, one for
odd
> rows, one for even), and then reuse those styles?
>
> So ... The code/pseudocode might look like ...
>
> HSSFCellStyle  HeadStyle = Workbook.createCellStyle();
> HSSFCellStyle  OddStyle = Workbook.createCellStyle();
> HSSFCellStyle  EvenStyle = Workbook.createCellStyle();
>
> HeadStyle.setFillBackgroundColor(HSSFCellStyle.RED);
> OddStyle.setFillBackgroundColor(HSSFCellStyle.GREEN);
> EvenStyle.setFillBackgroundColor(HSSFCellStyle.BLUE);
>
> ...
>
> if ( (HSSFRow.getRowNum() mod 2) == 0)
>   Cell.setCellStyle(EvenStyle);
> else
>   Cell.setCellStyle(OddStyle);
>
> ...
>
>
> ?
>
> Curtis
>
> -----Original Message-----
> From: Felipe Castro [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 11, 2004 9:06 AM
> To: POI Users List
> Subject: Re: Question about Cell Styles in Excell
>
>
> I see, but I don't know beforehand how many rows I'll write. Also, the
> "table" I'm trying to write should be "centered" on the sheet for
> readability. I don't use the upper, lower, left and rightmost rows and
> columns of my sheet. I don't know if templates would help...
>
>
> ----- Original Message ----- 
> From: "Karl-Heinz Zengerle" <[EMAIL PROTECTED]>
> To: "'POI Users List'" <[EMAIL PROTECTED]>
> Sent: Tuesday, May 11, 2004 11:49 AM
> Subject: AW: Question about Cell Styles in Excell
>
>
> > Hi Felipe.
> >
> > In Excel you can also set styles for whole rows or columns and then
> > override some styles of specific cells (e.g. header cells). So it should
> > also be possible in POI. This way the quantity of settings should be
> > small.
> >
> > When I hear alternating styles I'ld first think about styles on higher
> > level.
> >
> > Regards, Karl-Heinz.
> >
> >
> > -----Urspr�ngliche Nachricht-----
> > Von: Felipe Castro [mailto:[EMAIL PROTECTED]
> > Gesendet: Dienstag, 11. Mai 2004 16:39
> > An: POI Users List
> > Betreff: Re: Question about Cell Styles in Excell
> >
> >     Thank you for all your feedback..
> >
> >     Yes... I'm just trying to alternate colors on data rows. The need to
> > create different styles for each cell almost makes impracticable the use
> > of
> > POI for decently formatted sheets. Maybe POI could think of some kind of
> > style hierarchy or, at least, implement the "clone" method in the
> > HSSFCellStyle class. If one could clone a style, he could change only
> > the
> > cell data format and wouldn't need to reset all style properties for
> > each
> > cell with a different format.
> >
> >     I'm not sure but I thought of that in less than 5 minutes... There
> > must
> > be a good reason for not implementing it.
> >
> >     As for templates, I don't know exactly how to use them. Should I
> > create
> > an empty 2 line table (in the template) and use POI to get those lines
> > styles and aply them to new cells?
> >
> >     Thanks again,
> >
> >     Felipe
> >
> > ----- Original Message ----- 
> > From: "Mehner, Bj�rn" <[EMAIL PROTECTED]>
> > To: "POI Users List" <[EMAIL PROTECTED]>
> > Sent: Tuesday, May 11, 2004 4:38 AM
> > Subject: AW: Question about Cell Styles in Excell
> >
> >
> > >
> > >
> > > > Let me see if I get it straight. Please suppose I have a
> > > > simple table with 1 title row, two data rows and 6 columns.
> > > > Each of these rows has it's own fill color and each of the
> > > > data columns has it's own data format (the title row is, of
> > > > course, formed of strings). If the only way to set a fill
> > > > color and data format is by a cell style, does that mean that
> > > > I have to create 6 * 2 + 1 = 13 different cell styles to
> > > > accomplish the desired format? Is that right?
> > >
> > > Unfortunately I think you are right. Do you really have to have
> > > different colors each data row? Sounds strange to me. What are you
> > doing
> > > if the table has more than 2 rows? Alternating colours?
> > >
> > > ciao Bodo
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to