Bug 51469 - XSSFRow.setRowStyle not implemented
Summary: XSSFRow.setRowStyle not implemented
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2011-07-04 08:53 UTC by Alexander
Modified: 2011-07-08 14:58 UTC (History)
0 users

extraced xlsxs 'a' & 'b' (13.24 KB, application/x-zip-compressed)
2011-07-04 08:53 UTC, Alexander

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2011-07-04 08:53:27 UTC
Created attachment 27249 [details]
extraced xlsxs 'a' & 'b'

for HSSFRow there is setRowStyle method, XSSFRow lacks this method.

attached you'll find extracted xlsx a & b, the differing files are xl/worksheets/sheet1.xml resp.. in both files there is a '1' in cell A1, which has a certain format (bottom border black thin). in file 'b' the 1st row additionally has the same format set as row format.

the differing part is:

<row r="1" spans="1:1">
<row r="1" spans="1:1" 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()) { // + maybe something like: "|| _row.isSetCustomFormat()"
        } else {
            XSSFCellStyle xStyle = (XSSFCellStyle)style;

            long idx = _stylesSource.putStyle(xStyle);

the _stylesSource of XSSFRow could be handled exactly like for XSSFCell (as it's only a pointer to row.getSheet().getWorkbook().getStylesSource()).
Comment 1 Nick Burch 2011-07-08 14:58:49 UTC
Thanks for this investigating. I've added support for setting row styles to XSSF and SXSSF in r1144348, along with unit tests. I've also promoted the getter and setter to the Row interface