It is important to call the autoSizeColumn();
after data has been written to the sheet. I would include it right before the FileOutputStream out = ...
call. Like previous answers, auto size will take up lots of buffer space and should not be used on large sheets or SQL calls to data. It is better to define the columnSize
manually. For example:
sheet.setColumnSize(0, 10*256);
The first number is the column number, first column is Zero. Column width is calculated in 1/256ths of character width.