Bug 41919 - get maximum number of columns (or last col number) on sheet
Summary: get maximum number of columns (or last col number) on sheet
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2007-03-21 08:18 UTC by Glenn
Modified: 2009-05-19 00:49 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Glenn 2007-03-21 08:18:07 UTC
I need to read and analyze spreadsheets whose initial structure is not entirely
known a priori.  Since I could not find anything in the documentation about how
to do this, and the information which is available in a DimensionsRecord at a
low level did not seem to be accessible through the usermodel objects, I propose
adding the following method to usermodel.HSSFSheet:

    public int getLastColumnNum() {
    	List records = sheet.getRecords();
    	DimensionsRecord dim = (DimensionsRecord)records.get(sheet.getDimsLoc());
    	return dim.getLastCol();
Comment 1 David Fisher 2008-12-29 16:25:26 UTC
Sorry, but this doesn't make sense. You are better off finding the maximum column on each row of the sheet. Either way you are reading all of the sheet's records.
Comment 2 Toni Helenius 2009-05-19 00:49:45 UTC
It would make sense to some... For example I'm reading an Excel to a webpage. Some cells are empty and the webpage then doesn't look quite like the document on Excel. Perfect rectangle is the way to go. Then it is easiest to set out the row- and colspans as well when we know the dimensions before parsing the file.

There are alternative ways of course, but this made sense the most.