Bug 45518 - poi.ss.usermodel.Sheet.setColumnWidth(column, value) creates invalid code
Summary: poi.ss.usermodel.Sheet.setColumnWidth(column, value) creates invalid code
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-07-31 15:24 UTC by Paul Dobson
Modified: 2008-09-15 13:55 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
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)