poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nitin Nair" <NN...@hutchison.com.au>
Subject Re: Problem Creating Excel Sheets in JSP
Date Fri, 02 Sep 2005 12:31:21 GMT
Hi David,

Thanks for that.....
Is it possible  to generate an HTML/JSP from Servlet, that contains two
frames one with a normal HTML tags and other with the Excel embedded in
it..??

Regards
Nitin

>>> dfisher@jmlafferty.com 02.09.2005 9:58:38 pm >>>
Hi,

You need to produce binary files with a Servlet. JSP is for producing 

text data.

I had to learn this the hard way, our PDFs would always display until 

we hit the combination of Acrobat 6.02, Tomcat 4.1.29 and IE 6.0. One 

of the Tomcat developers corrected us, and a Servlet did solve the  
problem.

Shortly after that we found POI and starting producing XLS in a servlet
 
instead of a CSV text file.

You also will want to

             response.setContentType("application/vnd.ms-excel" );
             response.setHeader("Content-disposition",  
"inline;filename="+filename);

And we've also found that ending your url with "&ext=.xls" can help.

Note that this is all because of how MS IE "sniffs" file types.

Regards,
David Fisher

On Sep 2, 2005, at 4:52 AM, Nitin Nair wrote:

> Hi,
>
> I am trying to open an Excel document with multiple sheets using
HSSF
> POI. I have written the code for creating the Workbook and Worksheet
in
> the JSP. However when the JSP is invoked, nothing is displayed. I
have
> attached the JSP.
> I am creating the Worksheet in the following manner.
>
>
> response.setContentType("application/vnd.ms-excel");
> org.apache.poi.hssf.usermodel.HSSFWorkbook excelDoc = new
> org.apache.poi.hssf.usermodel.HSSFWorkbook();
> org.apache.poi.hssf.usermodel.HSSFSheet excelSheet =
> excelDoc.createSheet(sheetName);
>
															short
> rowCount = 0;
>
															org.apache.poi.hssf.usermodel.HSSFRow
> excelRow     = excelSheet.createRow((short)rowCount);
>
															excelRow.createCell((short)0).setCellValue("Date");
>
															excelRow.createCell((short)1).setCellValue("Time");
>
															excelRow.createCell((short)2).setCellValue("Timezone");
>
															excelRow.createCell((short)3).setCellValue("Called
> Number/Email/Network Address");
> 															

> excelRow.createCell((short)4).setCellValue("Destination");
>
															excelRow.createCell((short)5).setCellValue("Invoice
> Text");
>
															excelRow.createCell((short)6).setCellValue("Billed
> Qty");
>
															excelRow.createCell((short)7).setCellValue("Volume");
>
															excelRow.createCell((short)8).setCellValue("Total
> Charge");
>
															excelRow.createCell((short)9).setCellValue("Time
> Band");
>
															excelRow.createCell((short)10).setCellValue("Usage
> Category");
>
															excelRow.createCell((short)11).setCellValue("Event
> Type Code");
>
															excelRow.createCell((short)12).setCellValue("Event
> Sub Type Code");
>
															rowCount++;
>
>
> Any help will be highly appreciated.
> Regards
> Nitin
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org 
> Mailing List:    http://jakarta.apache.org/site/mail2.html#poi 
> The Apache Jakarta POI Project: http://jakarta.apache.org/poi/ 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org 
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/ 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


Mime
View raw message