Bug 55968 - [PATCH] Method autoSizeColumn with images
Summary: [PATCH] Method autoSizeColumn with images
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.9-FINAL
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Keywords: PatchAvailable
Depends on:
Reported: 2014-01-07 17:50 UTC by Rafael Moreti Santana
Modified: 2016-03-12 20:52 UTC (History)
1 user (show)

Java Class with method autosizeCollum modified in case of images (698 bytes, text/x-java)
2014-01-07 17:50 UTC, Rafael Moreti Santana
autosizeColumn JUnit test (668 bytes, text/x-java)
2014-01-15 15:42 UTC, Rafael Moreti Santana

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Moreti Santana 2014-01-07 17:50:56 UTC
Created attachment 31179 [details]
Java Class with method autosizeCollum modified in case of images

method autosizeColumn doesn't work right with images. The attachment has the repaired method.
Comment 1 Nick Burch 2014-01-08 14:36:10 UTC
Are you able to produce a unit test for this, and provide some documentation / javadocs / etc to help people work out when they'd want to use the current behaviour, and when they might want to use this instead?
Comment 2 Rafael Moreti Santana 2014-01-14 11:44:25 UTC
Sorry, the JUnit tests are from the company and they can't be shared. There is any test framework you use that can be shared so we can generate tests and post it here? I will send a documentation as soon as possible.
Comment 3 Rafael Moreti Santana 2014-01-15 15:42:31 UTC
Created attachment 31210 [details]
autosizeColumn JUnit test
Comment 4 Rafael Moreti Santana 2014-01-15 15:45:34 UTC
Just added attachment that contains a JUnit test of the modified method autosizeColumn. The test is based on the JUnit test of class TestXSSFSheet of POI 3.7. The modified method autosizeColumn can be used in any case, if the sheet contains an image or not.
Comment 5 Javen O'Neal 2016-03-12 20:49:23 UTC
Setting column width and auto-sizing columns in POI 3.14 is done via Sheet.get/setColumnWidth [1] and Sheet.autoSizeColumn [2]. 

The attached patch duplicates current functionality, so it looks like your problem of setting custom column widths is solved.

[1] https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Sheet.html
[2] https://poi.apache.org/spreadsheet/quick-guide.html#Autofit
Comment 6 Javen O'Neal 2016-03-12 20:52:15 UTC
Please reopen if you have code that can auto-sizing to image or chart width.