Summary: | Image is reversed on a very wide column. | ||
---|---|---|---|
Product: | POI | Reporter: | Pooja <poojapk_30> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED WONTFIX | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 3.1-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Attachments: |
sample program to demonstrate issue
updated standalone sample junit to demonstrate the problem Image used by sample program |
I haven't looked into this at all, but I wonder if it might be a signed vs unsiged 16 bit integer issue. That'd be my first hunch on where to investigate Your sample programs uses unresolved ReportWriterHelper.convertPixelsToCharacters and ReportWriterHelper.convertPixelsToPoints. Please re-attach an isolated test case. Also attach the image you are using for the header. Yegor Created attachment 23231 [details]
updated standalone sample junit to demonstrate the problem
Created attachment 23232 [details]
Image used by sample program
Please update the path of the image file on line 91 of the sample program to point to this image file.
The standalone junit to demonstrate the issue and the image file used are uploaded. Please update file path in line 91 of sample program to point to the image file attached. If you comment line 46 where the width of the column is set to a very large value, the excel generated has the image placed properly. Uncomment it and the image in the excel is reversed. Nick's supposition is right, it is a signed vs unsiged 16 bit integer issue. 1. The following fragment (lines 64-66) is wrong: float cellWidth = convertPixelsToCharacters(columnWidths[c] * 256f); sheet.setColumnWidth((short) (columnIndex), (short) cellWidth); If cellWidth > Short.MAX_VALUE then the casting to short produces a negative value. 2. setColumnWidth / getColumnWidth with short arguments are deprecated. Use setColumnWidth(int columnIndex, int width) and int getColumnWidth(int columnIndex) In particular, getColumnWidth(short columnIndex) return a short value. If column width measured in 1/256th units is in the interval [32767, 65536] then this method returns a negative value which is evidently incorrect. 3. The maximum column width for an individual cell in Excel is 255 characters. I changed the code to throw IllegalArgumentException if this limit is exceeded. Regards, Yegor (In reply to comment #6) > ... > 3. The maximum column width for an individual cell in Excel is 255 characters. > I changed the code to throw IllegalArgumentException if this limit is exceeded. > ... svn r741678 |
Created attachment 23146 [details] sample program to demonstrate issue I am creating and excel worksheet , the width of whose columns may vary. There is an image on the top row - anchores to one of the last columns of the sheet. When the width of the column containing the image is very wide (say 1000 pixels), the image is reversed and placed on the column before the column where the image is anchored. A sample program to demonstrate the issue is attached.