We are using the Display tag library in our Java based web application.
Apart from just using display tag library to show lists, we are also using it to export data to excel sheets which is working fine.
The problem is that the data is wrapped up in the Excel sheet columns.
I need to click on the cell to expand the cell to see the complete data.
Is there any way to prevent this wrapping up of data? Can Excel sheet cells adjust themselves to the width of the data in it?
Yes cells can be autoformated, if you are using POI with it HSSF to create you document.
If not I'm suggesting you to use it just open an existing document and auto resize columns you need.
After you created all your cells but before saving document you just call this method that re-size column. for example i did it for all of my columns on a sheet like that:
//
// Create an instance of workbook and sheet
//
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
sheet.setAutobreaks(true);
.
.//code in which you create actual rows and cells HERE
.
//auto formating to fit the page
for(int i=0; i<repModel.getReportHeaders().length;i++){
sheet.autoSizeColumn((short) (i+1));
}
And here is a best link to use to start up with poi: Busy Developers' Guide to HSSF and XSSF Features