Bug 50277 - A more convenient API for accessing column information
Summary: A more convenient API for accessing column information
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-11-15 20:23 UTC by Trejkaz (pen name)
Modified: 2015-05-31 21:36 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Trejkaz (pen name) 2010-11-15 20:23:17 UTC
Currently the Sheet interface has a number of methods for accessing row information, in particular:

    org.apache.poi.ss.usermodel.Row getRow(int num);
    int getFirstRowNum();
    int getLastRowNum();

A similar API for columns would be useful:

    org.apache.poi.ss.usermodel.Column getColumn(int num);
    int getFirstColummNum();
    int getLastColumnNum();

This Column interface could be a proxy for the ColumnInfoRecord which has the data about the column, and would mirror the kind of methods the Row interface has, such as getting the width, hidden flag, styles and so forth.

The primary thing this would permit for us is a more efficient way to iterate over the columns.  Currently if we want to determine if any columns are hidden, we need to call isColumnHidden(int) once for each column, which runs the iterator once for each call.  For a large number of columns this is a significant performance hit as the operation becomes O(n^2).
Comment 1 Nick Burch 2014-07-30 23:18:02 UTC
This would need implementations for both HSSF and XSSF, and would also need logic on things like Row.createCell() to update the lastColumnNumber information as the sheet data grows

It would hopefully be a fairly small enhancement to make, if someone fancies tackling this....!
Comment 2 Dominik Stadler 2015-05-31 21:36:57 UTC
These methods are available since a long time now...