Bug 51504 - NullPointerException in InternalSheet.getColumnWidth() due to missing defaultcolwidth
Summary: NullPointerException in InternalSheet.getColumnWidth() due to missing default...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.8-dev
Hardware: PC Windows Vista
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-13 15:40 UTC by Sergey Vladimirov
Modified: 2011-07-15 09:21 UTC (History)
0 users



Attachments
proposed patch based on different open source projects (i.e. googled for constant) (3.46 KB, patch)
2011-07-15 05:05 UTC, Sergey Vladimirov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Vladimirov 2011-07-13 15:40:03 UTC
public void testGetColumnWidth()
    {
        InternalSheet worksheet = InternalSheet.createSheet();
        // shall not be NPE
        worksheet.getColumnWidth( 0 );

        HSSFWorkbook wb = HSSFTestDataSamples
                .openSampleWorkbook( "12843-1.xls" );
        HSSFSheet sheet = wb.getSheetAt( 7 );
        // shall not be NPE
        sheet.getColumnWidth( 0 );
    }


Second call to getColumnWidth() throws NPE due to missing defaultcolwidth
Comment 1 Sergey Vladimirov 2011-07-13 15:46:27 UTC
Also happens with 34775.xls, 44010-SingleChart.xls,  44010-TwoCharts.xls.

Seems defaultcolwidth may miss if sheet contains only charts
Comment 2 Sergey Vladimirov 2011-07-15 05:05:01 UTC
Created attachment 27286 [details]
proposed patch based on different open source projects (i.e. googled for constant)
Comment 3 Yegor Kozlov 2011-07-15 09:21:46 UTC
Applied in r1147049 along with a unit test. 

The proposed defaults agree with the Excel documentation. The default column width in Excel is eight characters (this is true for both binary and OOXML formats). The default row height is 255 twips (12.75 pt). 

Regards,
Yegor