Bug 53414 - Dimension of the sheet not updated properly when adding column
Summary: Dimension of the sheet not updated properly when adding column
Status: VERIFIED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.8-FINAL
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-14 06:50 UTC by alex
Modified: 2017-03-03 13:09 UTC (History)
0 users



Attachments
Implements the suggested fix (501 bytes, patch)
2012-06-14 06:51 UTC, alex
Details | Diff
Testcode that produces an excel that contains the wrong dimensions (872 bytes, application/octet-stream)
2012-06-14 07:25 UTC, alex
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alex 2012-06-14 06:50:45 UTC
Our excel generation is based on templates where we duplicate rows and columns as necessary to fit the data that is fed into them. In this particular usecase we add 23 rows and one column. Our counterparty uses jxl 2.5.5 to parse the incoming xls files generated by our poi setup. The added rows do not pose a problem but the added column does. The problem is that the values in the added column are not parsed and instead jxl outputs warnings:

Warning: Cell D1 exceeds defined cell boundaries in Dimension record (3x42)
Warning: Cell D2 exceeds defined cell boundaries in Dimension record (3x42)
Warning: Cell D3 exceeds defined cell boundaries in Dimension record (3x42)
Warning: Cell D4 exceeds defined cell boundaries in Dimension record (3x42)
Warning: Cell D5 exceeds defined cell boundaries in Dimension record (3x42)

You will note that more recent version of jxl do parse the excel correctly but only because they adjusted their error handling. The excels generated by apache poi still seem to have the wrong dimension.

Updating the org.apache.poi.hssf.model.InternalSheet.addValueRecord() method from if (col.getColumn() > d.getLastCol())  to if (col.getColumn() >= d.getLastCol()) fixes the problem in our usecase.
Comment 1 alex 2012-06-14 06:51:34 UTC
Created attachment 28939 [details]
Implements the suggested fix
Comment 2 Yegor Kozlov 2012-06-14 07:02:27 UTC
Any chance you upload a junit test case for your patch? 

Regards,
Yegor
Comment 3 alex 2012-06-14 07:25:58 UTC
Created attachment 28940 [details]
Testcode that produces an excel that contains the wrong dimensions
Comment 4 alex 2012-06-14 07:54:49 UTC
Please note that if you open the generated xls file in excel, it automatically fixes the dimension issue (judging from the last modified even without explicitly hitting save)
Comment 5 alex 2012-06-26 08:13:35 UTC
Any progress on this issue? Will a fix be included in the library? Currently I'm running a locally patched version of poi and I'd rather not do that :)
Comment 6 Yegor Kozlov 2012-06-26 11:31:17 UTC
Fixed in r1353962, junit added.

Yegor
Comment 7 John Mickel A. Almeñe 2017-03-03 08:59:06 UTC
Hello everyone, i figure it out how to solve this problem. I simply update my jar file,  here's the link were you can download those jar file: http://www.java2s.com/Code/Jar/p/Downloadpoi39jar.htm
http://www.java2s.com/Code/Jar/p/Downloadpoiooxml39jar.htm
http://www.java2s.com/Code/Jar/p/Downloadpoiooxmlschemas39jar.htm
http://www.java2s.com/Code/Jar/j/Downloadjxl2612jar.htm

I hope this will help.
Comment 8 Javen O'Neal 2017-03-03 10:42:42 UTC
Apache POI developer note:
Please only download jars from sites you trust. You should always verify the checksums and signatures of the jars using the links on the official POI download page [1] to ensure the artifacts were not modified or corrupted.

You can find the latest versions as well as a link to archived releases on the official site.

[1] https://poi.apache.org/download.html#Available+Downloads
Comment 9 Mark Murphy 2017-03-03 13:09:27 UTC
I wounder if we can remove those links since it might be bad to advertise jars that we did not produce.