• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Writing xlsx document to servlet response

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following servlet code which sends request to generate excel file in xlsx format:



And in the middleware server

the final code which generates the excel doc in zip format is :



But I am not able to retrieve the excel in the frontend .
Could anyone please point out if I am missing some thing here ?

 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That code looks nasty. Are you trying to recreate the file format by zipping a collection of XML files? Why? Why not use Apache POI?
 
renisha suny
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please find attached the full source code where I am generating the Excel document
 
renisha suny
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following is the code snippet from where I iniitiate the request

ExcelWorkBookWriter ew = new ExcelWorkBookWriter();
LinkedHashMap sheets = new LinkedHashMap();
sheets.put("sheet1", null);
sheets.put("sheet2", null);
sheets.put("sheet3", null);
sheets.put("sheet4", null);
sheets.put("sheet5",null);
try {
ew.init("myxls.xlsx", sheets, null);
} catch (Exception e) {
logger.error("Exception handler " + e.getMessage(), e);
}
ew.importViewData(results);
ew.flushDataIntoWorkbook(exchange.getResponseBody());
 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch! I added some code tags to your post, which make it easier to read. What happens at the front end now? I'm confused by your mixing of Excel and zip files. Also, you set your content type to something that looks like it should be Excel, but then write a zip file?

My advice is to start small and build up. Can you write a working Excel file locally? Maybe start with just one sheet and not zipped. Can you use a servlet to download a simple text file? Once you get the pieces working, you can tie them all together.
 
Ulf Dittmer
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

renisha suny wrote:ExcelWorkBookWriter


What is that? Are you sure you're using it right?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic