poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 62673] New: XSSF worksheet has column range in dimension off by one
Date Tue, 04 Sep 2018 16:23:27 GMT

            Bug ID: 62673
           Summary: XSSF worksheet has column range in dimension off by
           Product: POI
           Version: 3.17-FINAL
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: richard.evans@blueallegro.net
  Target Milestone: ---

XSSFSheet has this code in the write method:

            if(row.getLastCellNum() != -1) {
                maxCell = Math.max(maxCell, row.getLastCellNum());

        if(minCell != Integer.MAX_VALUE) {
            String ref = new CellRangeAddress(getFirstRowNum(),
getLastRowNum(), minCell, maxCell).formatAsString();
            if(worksheet.isSetDimension()) {
            } else {

Arguments to the CellRangeAddress are zero-based:

         * Creates new cell range. Indexes are zero-based.

However row.getLastCellNum() returns the zero-based last cell number PLUS ONE:

     * @return short representing the last logical cell in the row <b>PLUS
     *   or -1 if the row does not contain any cells.

As a result the dimension in the worksheet has the last column number off by
one.  A single column sheet with five rows is written with 

<dimension ref="A1:B5"/>

instead of

<dimension ref="A1:A5"/>

You are receiving this mail because:
You are the assignee for the bug.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

View raw message