poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Hörnlein <hoernl...@uni-wuerzburg.de>
Subject Re: HSSFRow.setRowStyle -> XSSFRow.??? <- no such method
Date Tue, 28 Jun 2011 12:56:35 GMT
Am 21.06.2011 22:08, schrieb Nick Burch:
> On Tue, 21 Jun 2011, Alexander Hörnlein wrote:
>> we are just "upgrading" from HSSF to XSSF (because we need more 
>> columns). We use sometimes HSSFRow.setRowStyle for formatting, 
>> because there are null Cells which we don't want to create just to be 
>> able to apply a CellStyle. Now, in Row and XSSFRow, there is no such 
>> method.
>
> It looks like that support still needs to be added.
>
> I'd suggest you create a very simple xlsx file in excel, with say one 
> row styled and one not. Next, unzip the file and compare the two rows 
> to see how the styling is set. Then, check the microsoft docs on those 
> xml elements and attributes to check. Finally, add getters and setters 
> that work with the xmlbeans objects wrapping those xml bits, likely 
> wrapping them in appropriate xssf usermodel classes
>
> If you get it working, please do send in a patch!
>
> Nick
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org

ok - i created a xlsx with the style of the first row + the first cell 
set to the same style and another one where only the first cell has the 
style and the only difference was

<row ...> ...
vs.
<row ... s="1" customFormat="1">....

so i guess the code from XSSFCell should work for XSSFRow (+ 
customFormat), so it should be something like:

     public void setCellStyle(CellStyle style) {
         if(style == null) {
             if(_row.isSetS()) {
                 _row.unsetS();
                 _row.unsetCustomFormat();
         } else {
             XSSFCellStyle xStyle = (XSSFCellStyle)style;
             xStyle.verifyBelongsToStylesSource(_stylesSource);

             long idx = _stylesSource.putStyle(xStyle);
             _row.setS(idx);
             _row.setCustomFormat(true);
         }
     }

the _stylesSource of XSSFRow could be handled exactly like for XSSFCell 
(it's only a pointer to row.getSheet().getWorkbook().getStylesSource();

-- 
alexander

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message