Title: FW: Conditional Cell Styling
You need to create a completely new cell style option for cs2.  You are just copying the pointer in the statement cs2 = cs so that cs and cs2 points to the same object.
 

Shawn Laubach
SAIC - Web Developer
-----Original Message-----
From: Hatzenbeler, Tim [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 12:15 PM
To: '[EMAIL PROTECTED]'
Subject: FW: Conditional Cell Styling

I was trying to test the rotation feature, and I can't seem to make this work using this setup.

I was using (2) different cellstyling object, and then on a praticular row, set styling to cs, and on the other rows set it to cs2, but it seems that the cs2 object overwrites the cs object when it write the spreadsheet. 

Thanks, tim

        s.setColumnWidth((short) 1, (short) (256*30));

        cs.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        cs.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        cs.setBorderRight(HSSFCellStyle.BORDER_THIN);
        cs.setBorderTop(HSSFCellStyle.BORDER_THIN);
        cs.setFillForegroundColor(HSSFCellStyle.YELLOW);
        cs.setFillPattern(HSSFCellStyle.AQUA);
       
        fnt.setColor(HSSFFont.RED);
        fnt.setItalic(true);
        cs.setFont(fnt);
       
        cs2 = cs;
        cs2.setRotation((short) 90);
        cs2.setFillForegroundColor(HSSFCellStyle.GREEN);
        fnt.setColor(HSSFFont.GREEN);
        fnt.setItalic(true);
        cs2.setFont(fnt);

.....

            while (rs.next()) {
                r = s.createRow(row);
               
                if (row == 2) {                                  /**** this worked ****/
                      r.setHeight((short) 1500);
                    }
                               cell++;
                               c = r.createCell(cell, HSSFCell.CELL_TYPE_STRING);
                               c.setCellValue(rs.getString("LSTNAM"));
        
/***** Problem ***/                if (row == 5) {                                 
                                                             c.setCellStyle(cs);

                            }
                     else {
                                                             c.setCellStyle(cs2);

                  }

Reply via email to