Bug 10935

Summary: [PATCH] Sheet.getColumnWidth sometimes doesnt return the correct width
Product: POI Reporter: Jason Height <jheight>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: chriswhalen
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: Patch to Sheet.java
TestHSSFSheet patch for column width test. Please commit both patches

Description Jason Height 2002-07-18 03:45:24 UTC
The Sheet.getColumnWidth and Sheet.setColumnWidth if test within the for loop 
is not right so when the column lies within a columninfo range it doesnt return 
the correct columninfo object

Patch which corrects will be supplied immediately.

Patch to the unit tests to follow, so that the problem doesnt happen again.
Comment 1 Jason Height 2002-07-18 03:46:17 UTC
Created attachment 2390 [details]
Patch to Sheet.java
Comment 2 Jason Height 2002-07-18 04:39:23 UTC
Created attachment 2393 [details]
TestHSSFSheet patch for column width test. Please commit both patches
Comment 3 Andy Oliver 2002-07-18 12:19:15 UTC
After applying, here's what I get when doing ./build.sh clean compile test
please fix and reopen/attach and/or let me know what I'm doing wrong Thanks! ->

Compiling project examples with Java 1.3, debug on, optimize off, deprecation on

Compiling project contributions with Java 1.3, debug on, optimize off, deprecati
on on

test:
Created dir: D:\andy\homestuff\jakarta-poi2\2\jakarta-poi\build\testcases
Compiling 103 source files to D:\andy\homestuff\jakarta-poi2\2\jakarta-poi\build
\testcases
D:\andy\homestuff\jakarta-poi2\2\jakarta-poi\src\testcases\org\apache\poi\hssf\u
sermodel\TestHSSFSheet.java:206: getColumnWidth(short) in org.apache.poi.hssf.us
ermodel.HSSFSheet cannot be applied to (int)
        assertEquals(sheet.getDefaultColumnWidth(), sheet.getColumnWidth(0));
                                                         ^
D:\andy\homestuff\jakarta-poi2\2\jakarta-poi\src\testcases\org\apache\poi\hssf\u
sermodel\TestHSSFSheet.java:207: setColumnWidth(short,short) in org.apache.poi.h
ssf.usermodel.HSSFSheet cannot be applied to (int,int)
        sheet.setColumnWidth(0, 9000);
             ^
D:\andy\homestuff\jakarta-poi2\2\jakarta-poi\src\testcases\org\apache\poi\hssf\u
sermodel\TestHSSFSheet.java:208: getColumnWidth(short) in org.apache.poi.hssf.us
ermodel.HSSFSheet cannot be applied to (int)
        assertEquals(9000, sheet.getColumnWidth(0));
                                ^
D:\andy\homestuff\jakarta-poi2\2\jakarta-poi\src\testcases\org\apache\poi\hssf\u
sermodel\TestHSSFSheet.java:209: setColumnWidth(short,short) in org.apache.poi.h
ssf.usermodel.HSSFSheet cannot be applied to (int,int)
        sheet.setColumnWidth(2, 8000);
             ^
D:\andy\homestuff\jakarta-poi2\2\jakarta-poi\src\testcases\org\apache\poi\hssf\u
sermodel\TestHSSFSheet.java:210: getColumnWidth(short) in org.apache.poi.hssf.us
ermodel.HSSFSheet cannot be applied to (int)
        assertEquals(8000, sheet.getColumnWidth(2));
                                ^
5 errors

BUILD FAILED
D:\andy\homestuff\jakarta-poi2\2\jakarta-poi\tools\cents\junit.cent\xbuild.xml:2
7: Compile failed; see the compiler error output for details.

Total time: 1 minute 37 seconds
Comment 4 Andy Oliver 2002-07-18 14:59:59 UTC
I fixed ti
Comment 5 Andy Oliver 2002-07-18 15:01:09 UTC
Applied, please cross check.  In the future please make sure you run "./build.sh
clean compile test" before submitting the patches.  Thanks for your patch!
Comment 6 Andy Oliver 2002-07-21 13:13:09 UTC
*** Bug 8906 has been marked as a duplicate of this bug. ***