Bug 13483

Summary: [PATCH] getNumMergedRegions() throws NullPointerException
Product: POI Reporter: Jens Gerhard <gerhajns>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: kamoshida.toshiaki, weitang
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: other   
Attachments: Patch for sheet.java

Description Jens Gerhard 2002-10-10 11:52:59 UTC
org.apache.poi.hssf.model.Sheet:
org.apache.poi.hssf.usermodel.HSSFSheet:

Description:
If the actual sheet has no merged cells, the member "merged" was null and the
method getNumMergedRegions() throws an exception (NullPointerException). 
I'm converting with this method excel files to html-tables and I'm using the
regions to handle colspans and rowspans for the html-table output. 

Idea for a solution:
* Add a method "hasSheetSomeRegions()" to the class Sheet.java and
HSSFSheet.java for checking the member "merged" is null 
or
* extends the method "geNumMergedRegions()" like this:

    public int getNumMergedRegions()
    {
        return merged!=null ? merged.getNumAreas() : 0;
    }


Regards
Jens
Comment 1 Andy Oliver 2002-10-10 15:35:19 UTC
supply this as a CVS diff -u patch per the instructions on the "get involved"
page and I'll apply it.  Also getMergedRegions shoud just return 0 if merged is
null.  This is a bug.
Comment 2 Jens Gerhard 2002-10-11 05:59:09 UTC
Created attachment 3423 [details]
Patch for sheet.java
Comment 3 Andy Oliver 2002-11-28 19:05:11 UTC
Applied.  Thanks!  Please cross check.  Next time remember to add yourself to
the @author tags.
Comment 4 Toshiaki Kamoshida 2002-12-04 06:17:54 UTC
*** Bug 14919 has been marked as a duplicate of this bug. ***
Comment 5 Tang Wei 2003-04-14 02:11:11 UTC
public int getNumMergedRegions()
    {
        return merged.getNumAreas();
    }

but "merged" now is null.