Bug 45518

Summary: poi.ss.usermodel.Sheet.setColumnWidth(column, value) creates invalid code
Product: POI Reporter: Paul Dobson <pdobson>
Component: POI OverallAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Paul Dobson 2008-07-31 15:24:55 UTC
poi.ss.usermodel.Sheet.setColumnWidth(column, value); method creates invalid XML when setting the column width for column 0.

short column = 0
short value = 10
wb = new XSSFWorkbook();
Sheet workSheet = wb.createSheet("Report");
workSheet.setColumnWidth(column, value); //creates invalid XML

The above code generates the following invalid XML in the sheet1.xml file:

<col min="0" max="0" width="10"/>

It likely should create


<col min="1" max="1" width="10"/>

The code is invalid because columns start a 1, not 0 in xlsx files.  HSSF starts columns at 0

Discussion on dev user list is that XSSF columns should be 0 based and create XML that is 1 based so that the method behaves the same as in HSSF. In any case, it seems to me that an exception should be thrown before allowing invalid XML to be generated for an invalid column.
Comment 1 Nick Burch 2008-09-15 13:55:33 UTC
Now fixed in svn (affected more than just setColumnWidth, so took a little while to sort out)