Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6042387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:47:04+00:00 2026-05-23T06:47:04+00:00

Im with a different problem… I’ve googled a little but havent found anything about

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:47:05+00:00Added an answer on May 23, 2026 at 6:47 am

    You can generate the report as PDF(or other format) and send it as a file with Jasper.
    JRXlsExporter

    some snippet:

    JasperPrint print = JasperFillManager.fillReport(report, new HashMap(), jasperReports); 
    long start = System.currentTimeMillis(); 
    
    OutputStream output = new FileOutputStream(new File("c:/output/JasperReport.pdf")); 
    JasperExportManager.exportReportToPdfStream(print, output); 
    
    // coding For Excel: 
    
    
    JRXlsExporter exporterXLS = new JRXlsExporter(); 
    exporterXLS.setParameter(JRXlsExporterParameter.JA SPER_PRINT, print); 
    exporterXLS.setParameter(JRXlsExporterParameter.OU TPUT_STREAM, output); 
    exporterXLS.setParameter(JRXlsExporterParameter.IS _ONE_PAGE_PER_SHEET, Boolean.TRUE); 
    exporterXLS.setParameter(JRXlsExporterParameter.IS _AUTO_DETECT_CELL_TYPE, Boolean.TRUE); 
    exporterXLS.setParameter(JRXlsExporterParameter.IS _WHITE_PAGE_BACKGROUND, Boolean.FALSE); 
    exporterXLS.setParameter(JRXlsExporterParameter.IS _REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE); 
    exporterXLS.exportReport(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I have two spreadsheets that each serve different purposes but contain one particular
A question similar to Locating bundles by identifier , but different problem: I have
I know the questions sounds very familiar on SO but I have different problem
I have the same scenario as this question, but with a different problem: ASP.Net
problem is that I have to checkout a different branch for every project. and
This is related to my previous question but it is a different problem. I
EDIT: So apparently I was doing everything right, but I had a different problem
Here's an overview of my problem: I have a templated class called TWMatrix. I've
I have a quite different problem with resizing. I have a Flexbook component which
Guys, I have got a slightly different problem with Java Dynamic class loading. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.