net.sf.jasperreports.engine.util.JRLoader Java Examples

The following examples show how to use net.sf.jasperreports.engine.util.JRLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NoXmlDesignApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xlsx() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/NoXmlDesignReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");
	
	JRXlsxExporter exporter = new JRXlsxExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
	configuration.setOnePagePerSheet(false);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
}
 
Example #2
Source File: ScriptletApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void docx() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/ScriptletReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".docx");
	
	JRDocxExporter exporter = new JRDocxExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleDocxReportConfiguration configuration = new SimpleDocxReportConfiguration();
	configuration.setProgressMonitor(new SimpleExportProgressMonitor());
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("DOCX creation time : " + (System.currentTimeMillis() - start));
}
 
Example #3
Source File: QueryApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xlsx() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/QueryReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");
	
	JRXlsxExporter exporter = new JRXlsxExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
	configuration.setOnePagePerSheet(false);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
}
 
Example #4
Source File: DateRangeApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/DateRangeReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);
	
	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");
	
	JRXlsExporter exporter = new JRXlsExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
	configuration.setOnePagePerSheet(true);
	configuration.setDetectCellType(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #5
Source File: HibernateApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void csv() throws JRException
{
	File[] files = getFiles(new File("build/reports"), "jrprint");
	for(int i = 0; i < files.length; i++)
	{
		long start = System.currentTimeMillis();
		File sourceFile = files[i];

		JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

		File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".csv");
	
		JRCsvExporter exporter = new JRCsvExporter();
	
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
		exporter.setExporterOutput(new SimpleWriterExporterOutput(destFile));
	
		exporter.exportReport();

		System.err.println("Report : " + sourceFile + ". CSV creation time : " + (System.currentTimeMillis() - start));
	}
}
 
Example #6
Source File: ScriptletApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void ods() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/ScriptletReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".ods");
	
	JROdsExporter exporter = new JROdsExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleOdsReportConfiguration configuration = new SimpleOdsReportConfiguration();
	configuration.setOnePagePerSheet(true);
	configuration.setProgressMonitor(new SimpleExportProgressMonitor());
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("ODS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #7
Source File: JFreeChartApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/JFreeChartReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");
	
	JRXlsExporter exporter = new JRXlsExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #8
Source File: HibernateApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xlsx() throws JRException
{
	File[] files = getFiles(new File("build/reports"), "jrprint");
	for(int i = 0; i < files.length; i++)
	{
		long start = System.currentTimeMillis();
		File sourceFile = files[i];

		JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

		File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");
	
		JRXlsxExporter exporter = new JRXlsxExporter();
	
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
		exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
		SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
		configuration.setOnePagePerSheet(true);
		exporter.setConfiguration(configuration);
	
		exporter.exportReport();

		System.err.println("Report : " + sourceFile + ". XLSX creation time : " + (System.currentTimeMillis() - start));
	}
}
 
Example #9
Source File: UnicodeApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void ods() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/UnicodeReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".ods");

	JROdsExporter exporter = new JROdsExporter();

	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleOdsReportConfiguration configuration = new SimpleOdsReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);

	exporter.exportReport();

	System.err.println("ODS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #10
Source File: XChartApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/XYChart.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");
	
	JRXlsExporter exporter = new JRXlsExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #11
Source File: SubreportApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/MasterReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");
	
	JRXlsExporter exporter = new JRXlsExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #12
Source File: UnicodeApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/UnicodeReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");

	JRXlsExporter exporter = new JRXlsExporter();

	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);

	exporter.exportReport();

	System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #13
Source File: JasperFillManager.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Fills the compiled report design loaded from the specified file.
 * The result of this operation is another file that will contain the serialized  
 * {@link JasperPrint} object representing the generated document,
 * having the same name as the report design as declared in the source file, 
 * plus the <code>*.jrprint</code> extension, located in the same directory as the source file. 
 * 
 * @param sourceFileName source file containing the compiled report design
 * @param params     report parameters map
 * @see JRFiller#fill(JasperReportsContext, JasperReport, Map)
 */
public String fillToFile(
	String sourceFileName, 
	Map<String,Object> params
	) throws JRException
{
	File sourceFile = new File(sourceFileName);

	JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperReport.getName() + ".jrprint");
	String destFileName = destFile.toString();

	JasperPrint jasperPrint = JRFiller.fill(jasperReportsContext, 
			getReportSource(sourceFile, jasperReport), 
			params);

	JRSaver.saveObject(jasperPrint, destFileName);

	return destFileName;
}
 
Example #14
Source File: ListApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void pptx() throws JRException
{
	File[] files = getFiles(new File("build/reports"), "jrprint");
	for(int i = 0; i < files.length; i++)
	{
		long start = System.currentTimeMillis();
		File sourceFile = files[i];

		JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

		File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pptx");
	
		JRPptxExporter exporter = new JRPptxExporter();
	
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
		exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	
		exporter.exportReport();

		System.err.println("Report : " + sourceFile + ". PPTX creation time : " + (System.currentTimeMillis() - start));
	}
}
 
Example #15
Source File: UnicodeApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xlsx() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/UnicodeReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");

	JRXlsxExporter exporter = new JRXlsxExporter();

	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);

	exporter.exportReport();

	System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
}
 
Example #16
Source File: XmlDataSourceApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xlsx() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/CustomersReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");
	
	JRXlsxExporter exporter = new JRXlsxExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
}
 
Example #17
Source File: ScriptletApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/ScriptletReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");
	
	JRXlsExporter exporter = new JRXlsExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
	configuration.setOnePagePerSheet(true);
	configuration.setProgressMonitor(new SimpleExportProgressMonitor());
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #18
Source File: JRPdfExporter.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
protected Image getPxImage()
{
	if (pxImage == null)
	{
		try
		{
			pxImage =
				Image.getInstance(
					JRLoader.loadBytesFromResource(JRImageLoader.PIXEL_IMAGE_RESOURCE)
					);
		}
		catch(Exception e)
		{
			throw new JRRuntimeException(e);
		}
	}

	return pxImage;
}
 
Example #19
Source File: RenderableUtil.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public Renderable getRenderable(URL url, OnErrorTypeEnum onErrorType) throws JRException
{
	Renderable result;
	try
	{
		result = new JRImageRenderer(JRLoader.loadBytes(url));
	}
	catch (Exception e)
	{
		result = handleImageError(e, onErrorType); 
		
		if (log.isDebugEnabled())
		{
			log.debug("handled image error with type " + onErrorType + " for URL " + url, e);
		}
	}
	return result;
}
 
Example #20
Source File: SubreportApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xlsx() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/MasterReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");
	
	JRXlsxExporter exporter = new JRXlsxExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
}
 
Example #21
Source File: AbstractTest.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * This method is used for compiling subreports.
 */
public JasperReport compileReport(String jrxmlFileName) throws JRException, IOException
{
	JasperReport jasperReport = null;
	
	InputStream jrxmlInput = JRLoader.getResourceInputStream(jrxmlFileName);

	if (jrxmlInput != null)
	{
		JasperDesign design;
		try
		{
			design = JRXmlLoader.load(jrxmlInput);
		}
		finally
		{
			jrxmlInput.close();
		}
		jasperReport = JasperCompileManager.compileReport(design);
	}
	
	return jasperReport;
}
 
Example #22
Source File: XmlDataSourceApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void csv() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/CustomersReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".csv");
	
	JRCsvExporter exporter = new JRCsvExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleWriterExporterOutput(destFile));
	//exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, "|");

	exporter.exportReport();

	System.err.println("CSV creation time : " + (System.currentTimeMillis() - start));
}
 
Example #23
Source File: FormsApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xlsx() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/FormsReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");
	
	JRXlsxExporter exporter = new JRXlsxExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
}
 
Example #24
Source File: FontsApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xlsx() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/FontsReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");
	
	JRXlsxExporter exporter = new JRXlsxExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
	configuration.setOnePagePerSheet(false);
	exporter.setConfiguration(configuration);

	exporter.exportReport();

	System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
}
 
Example #25
Source File: CustomVisualizationApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void ods() throws JRException
{
	File[] files = getFiles(new File("build/reports"), "jrprint");
	for(int i = 0; i < files.length; i++)
	{
		long start = System.currentTimeMillis();
		File sourceFile = files[i];

		JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

		File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".ods");
	
		JROdsExporter exporter = new JROdsExporter();
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
		exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));

		SimpleOdsReportConfiguration configuration = new SimpleOdsReportConfiguration();
		configuration.setOnePagePerSheet(true);
		exporter.setConfiguration(configuration);
	
		exporter.exportReport();

		System.err.println("Report : " + sourceFile + ". ODS export time : " + (System.currentTimeMillis() - start));
	}
}
 
Example #26
Source File: DataSourceApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/DataSourceReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");
	
	JRXlsExporter exporter = new JRXlsExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
	configuration.setOnePagePerSheet(false);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #27
Source File: JasperExportManager.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Exports the generated report file specified by the parameter into XML format.
 * The resulting XML file has the same name as the report object inside the source file,
 * plus the <code>*.jrpxml</code> extension and it is located in the same directory as the source file.
 * <p>
 * When exporting to XML format, the images can be either embedded in the XML content
 * itself using the Base64 encoder or be referenced as external resources.
 * If not embedded, the images are placed as distinct files inside a directory
 * having the same name as the XML destination file, plus the "_files" suffix. 
 * 
 * @param sourceFileName    source file containing the generated report
 * @param isEmbeddingImages flag that indicates whether the images should be embedded in the
 *                          XML content itself using the Base64 encoder or be referenced as external resources
 * @return XML representation of the generated report
 * @see net.sf.jasperreports.engine.export.JRPdfExporter
 */
public String exportToXmlFile(
	String sourceFileName, 
	boolean isEmbeddingImages
	) throws JRException
{
	File sourceFile = new File(sourceFileName);

	/* We need the report name. */
	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".jrpxml");
	String destFileName = destFile.toString();
	
	exportToXmlFile(
		jasperPrint, 
		destFileName,
		isEmbeddingImages
		);
	
	return destFileName;
}
 
Example #28
Source File: HyperlinkApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/HyperlinkReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");
	
	JRXlsExporter exporter = new JRXlsExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
	configuration.setOnePagePerSheet(true);
	exporter.setConfiguration(configuration);
	
	exporter.exportReport();

	System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
 
Example #29
Source File: HibernateApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void ods() throws JRException
{
	File[] files = getFiles(new File("build/reports"), "jrprint");
	for(int i = 0; i < files.length; i++)
	{
		long start = System.currentTimeMillis();
		File sourceFile = files[i];

		JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

		File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".ods");
	
		JROdsExporter exporter = new JROdsExporter();
	
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
		exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
		SimpleOdsReportConfiguration configuration = new SimpleOdsReportConfiguration();
		configuration.setOnePagePerSheet(true);
		exporter.setConfiguration(configuration);
	
		exporter.exportReport();

		System.err.println("Report : " + sourceFile + ". ODS creation time : " + (System.currentTimeMillis() - start));
	}
}
 
Example #30
Source File: ListApp.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 *
 */
public void docx() throws JRException
{
	File[] files = getFiles(new File("build/reports"), "jrprint");
	for(int i = 0; i < files.length; i++)
	{
		long start = System.currentTimeMillis();
		File sourceFile = files[i];

		JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

		File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".docx");
	
		JRDocxExporter exporter = new JRDocxExporter();
	
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
		exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(destFile));
	
		exporter.exportReport();

		System.err.println("Report : " + sourceFile + ". DOCX creation time : " + (System.currentTimeMillis() - start));
	}
}