poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stephen.a.klein...@verizon.com
Subject HELP NEEDED re converting HSSFWorkbook and sending as mail attachment
Date Thu, 07 Oct 2004 13:54:12 GMT




Hi,
Does anyone know how (and hopefully have some code sample for) the best way
to take a HSSFWorkbook object and write it to Excel, and send it as an
attachement
to a mail (from a Java application), without having to write it to a file.

I'm using this code below, along with a Java mailer, but it's not quite
working.
The recipient does get an attachment, but it opens in excel with an error,
and some of the formatting is lost in the process.

Anyone see the problem,.......or have some code that works?
THANKS,
Steve

String toAddress = repParams.getemailName();
    String subject = repParams.getrptName();
    try{
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    hssfWorkbook.write(os);
    byte[] osByte = os.toByteArray();
    Emailer em = new Emailer(Emailer.MAILER_FOR_REPORTS);
    em.createMail("Successfully sent the report","Report.xls",osByte);
    em.setToAddress(toAddress);
    em.setSubject(subject);
    em.sendEmail();



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


Mime
View raw message