[Bug 61343] New: Sheet.getFirstRowNum() returns first non empty row

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 61343] New: Sheet.getFirstRowNum() returns first non empty row

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61343

            Bug ID: 61343
           Summary: Sheet.getFirstRowNum() returns first non empty row
           Product: POI
           Version: 3.16-FINAL
          Hardware: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: POI Overall
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

Created attachment 35173
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35173&action=edit
Sample spreadsheet

I have a spreadsheet with cell (3,6) i.e 3rd row and 6th column being populated
with some data. All other rows and columns of the sheet are empty.
While trying to read the Spreadsheet,  
     we use the function:
          sheet.getFirstRowNum() which returns 2 in this case. Expected value
is 0 as the sheet start from 0th row.

sheet.getRow() for 0th index returns null, ideally it should return row object
with empty value.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 61343] Sheet.getFirstRowNum() returns first non empty row

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61343

Javen O'Neal <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #1 from Javen O'Neal <[hidden email]> ---
The OOXML format allows for rows or cells to be missing. This is allows for
sheets to be sparse, consuming less memory and tim to load, and less time to
iterate through all the non-empty rows and cells.

The function getFirstRowNum() behaves as expected and documented in the
Javadocs.

By the way, the same is true for getLastRowNum().

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 61343] Sheet.getFirstRowNum() returns first non empty row

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61343

--- Comment #2 from Javen O'Neal <[hidden email]> ---
Refer to the Spreadsheet Quick Guide and examples for how to handle worksheets
that may contain empty rows or cells.

This is what you're looking for to return an empty row from a worksheet that
does not contain that row:

static Row getOrCreateRow(Sheet sheet, int rowIndex) {
    Row row = sheet.getRow(2);
    if (row == null) {
        row = sheet.createRow(2);
    }
    return row;
}

Conveniently, theres a function that is very similar to this in
org.apache.poi.ss.util.CellUtil.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...