poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dipak.Pa...@equant.com
Subject RE : export to EXcel from JSP using POI framework
Date Thu, 29 Apr 2004 15:24:03 GMT

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


Mime
View raw message