Bug 55644 - autoSizeColumn hiding columns
Summary: autoSizeColumn hiding columns
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 critical with 5 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
Keywords: JDK1.5
Depends on:
Reported: 2013-10-10 00:19 UTC by Jagadeesh
Modified: 2015-02-10 16:09 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Jagadeesh 2013-10-10 00:19:23 UTC
I generated one excel file using below program.
When I open excel in Office 2010, then column selected for autoSizeColumn is hiding.
If I remove the autoSizecolumn, then it works normally.

public class Automation 

	public static void main(String[] args) 

		XSSFWorkbook workbook = new XSSFWorkbook();
		XSSFSheet sheet = workbook.createSheet("students");
		  XSSFRow row = sheet.createRow(1);
		  XSSFCell cell = row.createCell(1);
			FileOutputStream fileOut = new FileOutputStream("workbook.xlsx");
		}catch(Exception e)


Comment 1 Nick Burch 2013-10-10 06:55:38 UTC
Is the column hidden, or just set to a zero width?
Comment 2 Jagadeesh 2013-10-10 19:48:23 UTC
Column is hiding.
After I select the columns and Right click -> Unhide, then I'm able to see the result.

(In reply to Nick Burch from comment #1)
> Is the column hidden, or just set to a zero width?
Comment 3 MS 2013-11-07 16:20:35 UTC
I'm getting the same behavior using Excel 2013 and poi 3.9
If you set a numeric value (even as a String) then the column is auto-sized correctly, for example:
Comment 4 Jonathan Crawford 2013-12-28 20:12:35 UTC
I am seeing the same behavior with JDK 1.6.0_45.
Comment 5 Dominik Stadler 2013-12-30 19:47:50 UTC
Tried with latest trunk and OpenOffice/LibreOffice, but could not reproduce, will try on Windows with Excel as well.
Comment 6 Dirk Dittert 2014-02-20 10:23:59 UTC
I have seen this behavior with POI-3.9 as well. Updating to POI-3.10 has resolved this issue for me.

The columns are not hidden but just have no width. The trick is to select all columns and then choose Show (last entry of context menu) to make them visible again.
Comment 7 Dominik Stadler 2014-09-01 14:11:00 UTC
I tried it with Excel 2013, the column is autosized correctly when using POI 3.11-beta2/trunk.

Therefore I am resolving this for now, please reopen with detailed version information if you still see this problem with recent versions of POI.
Comment 8 Sebastien Arod 2014-09-12 12:31:40 UTC

I never succeded to reproduce on a dev environment however this seems to always happen on some customers production environment using POI 3.9 and with different JVM versions.

I found a Stack Overflow topic that seems to be related to this bug (stackoverflow.com/a/14389179/1069454)

Is there a known list of steps/conditions required to reproduce this issue?

Could you also please clarify if the issue was reproduced at some point and fixed in 3.11 or if it was never reproduced by POI team. From the status (WORKSFORME) I guess it was never reproduced by POI team right?
Comment 9 Sebastien Arod 2014-09-14 14:22:30 UTC
I was able to reproduce the problem using poi 3.9.0, 3.10 and 3.11-beta2 on windows 7 with oracle jre 7u21. 

This works fine with jre 7u67 on windows 7.

I was not able to reproduce on ubuntu with oracle jre 7u21.
Comment 10 Sebastien Arod 2014-09-14 19:26:11 UTC
Debugging shows that using oracle jre 7u21 layout.getBounds().getWidth() returns 0 in org.apache.poi.ss.util.SheetUtil.getCellWidth(Cell, int, DataFormatter, boolean)

This may be related to this jdk bug https://bugs.openjdk.java.net/browse/JDK-8013716.

The problem can be mitigated by detecting when auto sizing fails and using a minimal width:

if (sheet.getColumnWidth(0) == 0) {
  // autosize failed use MIN_WIDTH
  sheet.setColumnWidth(0, MIN_WIDTH);
Comment 11 Nick Burch 2014-09-15 10:09:44 UTC
Upgrading to a non-broken JVM is probably the right fix here!
Comment 12 Dominik Stadler 2015-02-10 16:09:53 UTC
I also think that we rather should require an recently patched version of Java, therefore closing this WONTFIX for now. There are many security related and many bug fixes in those newer patchlevels, so upgrading is generally a good idea.