You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by PARIS Jean-Pierre FTRD/DMI/SOP <je...@francetelecom.com> on 2004/04/29 17:34:11 UTC

RE : RE : export to EXcel from JSP using POI framework

Hi,

What about trying to do that step by step as I wrote previously? Maybe generating the file on the server could help you to have a quick workaround...

Unfortunately, I have no servlet engine ready to be use for the moment! So I can't investigate much more... Are you in a hurry? I'll have to do the same thing as you in a couple of weeks...

In the last case (using response.getOutputStream), did you try 
	response.setHeader ("Content-Transfer-Encoding","8bit");
I can't remember what is the default value.

bye
jp

-----Message d'origine-----
De : PATEL Dipak EQUANT [mailto:dipak.patel@equant.com] 
Envoyé : jeudi 29 avril 2004 17:24
À : POI Users List
Objet : RE : export to EXcel from JSP using POI framework



Hi Jean-pierre ,

I tried using
response .getOutputStream(); and put it along with Worknbook object. as shown in the follwoing code.

//out.clear();
response.setContentType("application/ms-excel");
//response.setHeader ("Content-Transfer-Encoding","7bit");
response.setHeader("Content-Disposition","inline; filename =unknown.xls");

/*HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();

*/

//FileOutputStream outXls = new FileOutputStream("workbook.xls");

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("ATS Sheet");

// Create a row and put some cells in it. Rows are 0 based. HSSFRow row = sheet.createRow((short)0);

// Create a cell and put a date value in it. The first cell is not styled // as a date. HSSFCell cell = row.createCell((short)0); //cell.setCellValue(new Date());

// we style the second cell as a date (and time). It is important to // create a new cell style from the workbook otherwise you can end up // modifying the built in style and effecting not only this cell but other cells. HSSFCellStyle cellStyle = wb.createCellStyle(); //HSSFDataFormat hdf = new HSSFDataFormat(wb); //cellStyle.setDataFormat(hdf.getFormat("m/d/yy h:mm")); cell = row.createCell((short)1); cell.setCellValue("Test"); cell.setCellStyle(cellStyle);


OutputStream os = response.getOutputStream();

wb.write(os);
os.close();
os.flush();



However when it writes to excel spreadsheet it writes all junk data , instead of cell values I am setting in my spreadsheet.

Don't know what else can be done , if you could guide SVP.

DP






---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org