Problem in accessing Excel from my Java application


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Problem in accessing Excel from my Java application

  1. #1
    Join Date
    Feb 2005
    Posts
    1

    Angry Problem in accessing Excel from my Java application

    Purpose : I want to show some data from my oracle database in the form of excel sheet. For this I'm using POI Toolkit
    package: org.apache.poi.hssf.usermodel
    which is open source code available on apache' site.

    Now the problem is when I write to FileOutputStream, it works fine. But when I write to outputstream, it gives me junk values.

    I have created a wraper class - ExcelGenerator and this the code I'm using in the the test jsp


    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition","inline;filename=sample.xls");
    OutputStream os = response.getOutputStream();
    FileOutputStream fs = new FileOutputStream("MyWorkbook.xls");
    System.out.println("Output Stream = "+os.toString());

    ExcelGenerator eg = new ExcelGenerator();
    eg.createSample();
    HSSFWorkbook wb = eg.getWorkBook();
    wb.write(os);
    wb.write(fs);
    os.flush();
    fs.flush();
    os.close();


    Any clues/ suggestions most welcome

    Anirudh

  2. #2
    Join Date
    May 2004
    Location
    Durham, UK
    Posts
    174
    Hi,

    have a look at http://java2.5341.com/msg/44383.html and
    see if it helps.
    Hope this helps
    Graham

    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, and if they get mad, you are a mile away and you have their shoes ;-)

    http://www.grahamrobinsonsoftware.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center