jferard / fastods

A very fast and lightweight (no dependency) library for creating ODS (Open Document Spreadsheet, mainly for Calc) files in Java. It's a Martin Schulz's SimpleODS fork
GNU General Public License v3.0
36 stars 6 forks source link

Cell merge only merge cells horizontally #137

Closed rsribeiro closed 5 years ago

rsribeiro commented 5 years ago

Method setCellMerge is only merging cells horizontally. I tested a fix by moving the content to a new private method setColumnsSpanned and adding a call to setRowsSpanned:

public void setCellMerge(final Table table, final TableAppender appender, final int rowIndex,
                         final int colIndex, final int rowCount, final int columnCount)
        throws IOException {
    this.setRowsSpanned(table, appender, rowIndex, colIndex, rowCount);
    this.setColumnsSpanned(table, appender, rowIndex, colIndex, rowCount, columnCount);
}

private void setColumnsSpanned(final Table table, final TableAppender appender, final int rowIndex,
        final int colIndex, final int rowCount, final int columnCount)
        throws IOException {
    final TableRow row = this.getRowSecure(table, appender, rowIndex, true);
    if (row.isCovered(colIndex)) // already spanned
        return;

    row.setColumnsSpanned(colIndex, columnCount);
    this.spanColumnsFromRowsBelow(table, appender, rowIndex, colIndex, rowCount, columnCount);
}
jferard commented 5 years ago

Hi! I'll have a look at this.

jferard commented 5 years ago

@rsribeiro I think it's fixed now. I used a different method than the one you provided, but I guess the result is the same. I added an integration test to check this, it seems ok to me. Could you retry with the last version ? BTW thanks for the precise feedback!

rsribeiro commented 5 years ago

It worked for me now, thanks.