JAVA+POI API Excel- Need to increase width of the column
apache-poi, java
Solution
This should work. However,
sampleDataSheet.autoSizeColumn(1000000);
auto-expands column 1000000.
If you want to auto-expand column 0(the first column), use:
sampleDataSheet.autoSizeColumn(0);
To auto-expand column 0 to 9(the first 10 columns):
for (int i=0; i<10; i++){
sampleDataSheet.autoSizeColumn(i);
}
Also, you should create all your rows and fill them with content first, before you call autoSizeColumn(so the column gets the width of the value with the broadest width).
(If you want to set the column width to a fixed value, use HSSFSheet.setColumnWidth(int,int) instead.)
Problem
I want to increase the width of the column of excel sheet. as the i am writing trough code is long. and I need to drag the column manually to see the full text. I did this – ``` HSSFRow dataRow = sampleDataSheet.createRow(0); HSSFCellStyle cellStyle = setHeaderStyle(sampleWorkbook); cellStyle.setWrapText(true); ***sampleDataSheet.autoSizeColumn(1000000);*** ``` But its not changing anything..