开发者

How to create excel file in servlet for google app engine application?

开发者 https://www.devze.com 2023-04-03 04:43 出处:网络
i am developing cloud application which is hosted on google app engine and in this i want to generate excel file on click of but开发者_如何学Goton through servlet.

i am developing cloud application which is hosted on google app engine and in this i want to generate excel file on click of but开发者_如何学Goton through servlet.

i have done it on local machine but when i deploy my application on app engine it shows error HTTP Error 500 Internal server error

i am using jxl java api for generating excel file

code that i have used is here

try 
{
  //i have used following content type but didn't worked..... 
  //response.setContentType("application/CSV");
  //response.setContentType("application/x-ms-excel");

  response.setContentType("application/vnd.ms-excel");
  WritableWorkbook w = Workbook.createWorkbook(response.getOutputStream()); 
  WritableSheet s = w.createSheet("Demo", 0);
  Label label = new Label(0, 2, "A label record"); 
  s.addCell(label);                   
  w.write();
  w.close();    
}
catch (Exception e)
{
      response.getOutputStream().println("Exception :"+e);
} 
finally
{

}   


I have used some code like this in the past to export CSV:

response.setHeader("Cache-Control", "");
response.setHeader("Pragma", "");
response.setHeader("Content-Disposition", "attachment; filename=foo.csv");
response.setContentType("text/csv");


What is the output of the println statement?

You are in trouble anyway though because as far as I can see, you can't use external libraries on Google App engine (and I don't think they have included that particular service).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号