Im with a different problem… I’ve googled a little but havent found anything about my problem so im asking here…
I have an object JasperPrint where i generate the document…
The problem is that i need to create a java.io.File from this JasperPrint without saving the file on the computer.
What do i need to do is: send a file by email. And this file must be generated by the jasperreport. I can’t save the stream on the machine to delete it later… so i need to take the file in memory or something like that in runtime…
So… i have my object jasperprint and need to get a java.io.File from this one…
Someone knows what do can i do?
Andrew… couldnt answer it at comment so im writing it here…
In javax.mail i’ve done like this:
File fileAttachment = myfile;
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(fileAttachment);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(fileAttachment.getName());
multipart.addBodyPart(messageBodyPart);
and its working when i pass him a file from my machine…
So i think its gonna work when i use a java.io.File even if its only on memory…
You can generate the report as PDF(or other format) and send it as a file with Jasper.
JRXlsExporter
some snippet: