jxls icon indicating copy to clipboard operation
jxls copied to clipboard

row height is not set to the template source row height when transform is streaming

Open iamforrest opened this issue 2 years ago • 0 comments

hello, I found that the generated rows height could not update to the template source row height when I use Sxssf transform.

template: image

result: image

After I debugged the last codes, I found that happened because sxssf transform ignores updating row heights in the method updateRowHeights completely.

PoiTransformer

public void updateRowHeight(String srcSheetName, int srcRowNum, String targetSheetName, int targetRowNum) {
        if (isSXSSF) return;
        SheetData sheetData = sheetMap.get(srcSheetName);
        RowData rowData = sheetData.getRowData(srcRowNum);
        Sheet sheet = workbook.getSheet(targetSheetName);
        if (sheet == null) {
            sheet = workbook.createSheet(targetSheetName);
        }
        Row targetRow = sheet.getRow(targetRowNum);
        if (targetRow == null) {
            targetRow = sheet.createRow(targetRowNum);
        }
        short srcHeight = rowData != null ? (short) rowData.getHeight() : sheet.getDefaultRowHeight();
        targetRow.setHeight(srcHeight);
    }

After I modified XlsArea.java as bellowing, the issue could be fixed:

line 442 and line 514: boolean updateRowHeight = parentCommand != null; change to boolean updateRowHeight = parentCommand != null || transformer.isForwardOnly();

I am not sure whether it is the best solution for this issue. Hope it helps. Thanks

iamforrest avatar May 03 '22 04:05 iamforrest