Bug 41919

Summary: get maximum number of columns (or last col number) on sheet
Product: POI Reporter: Glenn <gwghome>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED WONTFIX    
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

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.