I have tried the below to increase the column width as per data.Still i am unable to do it .Please suggest.Please refer attahced Excel file which is getting generated.Name column width is not set properly.we would like to apply the wrap after set column width.
code 1:
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
//============== Setting Row Height ==============
//Setting the height of the second row to 40
cells.setRowHeight(1, 40);
//Setting the height of all rows in the worksheet to 15
[//worksheet.getCells ](https://worksheet.getcells/)().setStandardHeight(15f);
//============== Setting Column Width ============
//Setting the width of the second column to 17.5
cells.setColumnWidth(1, 50);
Code 2:
worksheet.autoFitColumns();
We have evaluated the presented scenario while using the latest version of Aspose.Cells for Java 8.3.1, and we are unable to notice any problem with the column widths. The following piece of code works perfectly to extends the column widths according to the text length. We would request you to please download the latest version (links shared above) and give it a try on your end.
Java
Workbook wb = new Workbook(“test.xlsx”);
wb.getWorksheets().get(0).autoFitColumns();
wb.save(“output.xlsx”, SaveFormat.XLSX);
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.