I'm trying to build an excell file with apache. (HSSFWorkbook)
I cant figure out how to set column width size.
Look at the following example:
The first column (A) has the value: "row number" which we cant see the whole string. The columns (D) and (E) have the same problem, but If we double click on it we can see the full string.
I want to create cells which the user wouldn't need to double click on it. How can I do it ?
You can use autoSizecolumn()
which will set column size based on its header.
sheet.autoSizeColumn(0)// to adjust first column
Please refer this link. It would be helpful...
To set all the available columns , use a for
loop
for(int colNum = 0; colNum<row.getLastCellNum();colNum++)
workbook.getSheetAt(0).autoSizeColumn(colNum);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With