I also try to send a Poi generated Excel Sheet to a browser, with the
difference, that will only save the file for offline processing by the user. My
problem is, there something is going wrong whem I 'flush' the workbook to a
servlet output stream. It seems the header is corrupted cause I see a lot of
binary data and everything is written in one cell.

If I write the generated workbook in a file through a FileOutputStream
everything is ok. The file sizes are differ in 188 bytes.

Here is the code I use for sending the file to the browser

try
      {
        ExcelGenerator gen = new ExcelGenerator();
        HSSFWorkbook xlsSheet = gen.generateXlsDocument(vfCId);

        // for testing purposes
        File testFile = new File("c:\\tmp\\testj.xls");
        FileOutputStream fileOut = new FileOutputStream(testFile);
        xlsSheet.write(fileOut);
        fileOut.flush();

        response.setContentType("application/vnd.ms-excel");
        OutputStream output = response.getOutputStream();
        xlsSheet.write(output);
        output.flush();
      }
      catch (Exception e)
      {
        System.out.println("Error in SmartUpload::download");
      } 

Any hints what I'm doing wrong ?

Tia

J�rgen

> >
> >
> >Are some people interested in a complete JSP-POI simple working example
> (JSP
> >page and Excel servlet included)?
> >
> I Am.  Please provide patches once you figure out your problem and I 
> shall apply it.
> 
> For the JSP (still a bad idea IMHO), create a front servlet that just 
> maps the extension to xls and provides the
> mime type, as well as includes the content of your JSP passed in as a 
> parameter.  It wouldn't have to change much due
> to the limited functionality and the parameter.
> 
> -Andy
> 
> >  
> >
> >
> >
> >--
> >To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> >
> >  
> >
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to