How to prevent exported data from being packaged in excel using a display tag?

We use Display tag library in our Java based web application.

In addition to using the tag library to display lists, we also use it to export data for excellent sheets that work fine.

The problem is that the data is wrapped in the columns of an Excel worksheet.

I need to click on a cell to expand the cell to see the full data.

Is there any way to prevent this data packing? Can cells in an Excel worksheet adjust to the width of the data in it?

+5
source share
3 answers

, POI HSSF . , , , .
 

, , . , :

//
// 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));     
}

poi: HSSF XSSF

+2

, Excelance DisplayTag , Excel HSSF.

:

  • org.displaytag.export.BinaryExportView( DisplayTag DefaultHssfExportView)
  • , DisplayTag HssfTableWriter ( / DisplayTag , , )
  • ( ) HssfTableWriter ( , writeBottomBanner())
  • displaytag.properties : export.excel.class= x.y.z.MyExcelExportView

, DisplayTag 1.2 , , (http://displaytag.sourceforge.net/1.2/displaytag-export-poi/xref/org/displaytag/render/HssfTableWriter.html#347). DisplayTag 1.2 ? , , 1.2 . , , ""?

+2

If you use HSSF Poi to create an excel document, you should be able to adjust the column width:

http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFSheet.html#setColumnWidth%28int,%20int%29

+1
source

All Articles