/** * Exports the generated report file specified by the parameter into PDF format. * The resulting PDF file has the same name as the report object inside the source file, * plus the <code>*.pdf</code> extension and it is located in the same directory as the source file. * * @param sourceFileName source file containing the generated report * @return resulting PDF file name * @see net.sf.jasperreports.engine.export.JRPdfExporter */ public static String exportReportToPdfFile(String sourceFileName) 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() + ".pdf"); String destFileName = destFile.toString(); exportReportToPdfFile(jasperPrint, destFileName); return destFileName; }
protected void closeWorkbook(OutputStream os) throws JRException { try { workbook.write(os); } catch (IOException e) { throw new JRException("Error generating XLS report : " + jasperPrint.getName(), e); } }
protected void openWorkbook(OutputStream os) throws JRException { try { workbook = Workbook.createWorkbook(os); } catch (IOException e) { throw new JRException("Error generating XLS report : " + jasperPrint.getName(), e); } }
protected void setRowHeight(int y, int lastRowHeight) throws JRException { try { sheet.setRowView(y, (lastRowHeight * 20)); // twips } catch (RowsExceededException e) { throw new JRException("Error generating XLS report : " + jasperPrint.getName(), e); } }
/** * Exports the generated report file specified by the parameter into HTML format. * The resulting HTML file has the same name as the report object inside the source file, * plus the <code>*.html</code> extension and it is located in the same directory as the source file. * The images are placed as distinct files inside a directory having the same name * as the HTML destination file, plus the "_files" suffix. * * @param sourceFileName source file containing the generated report * @return resulting HTML file name * @see net.sf.jasperreports.engine.export.JRHtmlExporter */ public static String exportReportToHtmlFile( String sourceFileName ) 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() + ".html"); String destFileName = destFile.toString(); exportReportToHtmlFile( jasperPrint, destFileName ); return destFileName; }
File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".jrpxml"); String destFileName = destFile.toString();
/** * Fills a report and saves it directly into a HTML file. * The intermediate JasperPrint object is not saved on disk. */ public static String runReportToHtmlFile( String sourceFileName, Map parameters, JRDataSource jrDataSource ) throws JRException { File sourceFile = new File(sourceFileName); /* */ JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); parameters = JasperFillManager.setFileResolver(sourceFile, parameters); /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrDataSource); /* */ File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".html"); String destFileName = destFile.toString(); JasperExportManager.exportReportToHtmlFile(jasperPrint, destFileName); return destFileName; }
/** * Fills a report and saves it directly into a PDF file. * The intermediate JasperPrint object is not saved on disk. */ public static String runReportToPdfFile( String sourceFileName, Map parameters, Connection conn ) throws JRException { File sourceFile = new File(sourceFileName); /* */ JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); parameters = JasperFillManager.setFileResolver(sourceFile, parameters); /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); /* */ File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf"); String destFileName = destFile.toString(); JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); return destFileName; }
/** * Fills a report and saves it directly into a PDF file. * The intermediate JasperPrint object is not saved on disk. */ public static String runReportToPdfFile( String sourceFileName, Map parameters, JRDataSource jrDataSource ) throws JRException { File sourceFile = new File(sourceFileName); /* */ JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); parameters = JasperFillManager.setFileResolver(sourceFile, parameters); /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrDataSource); /* */ File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf"); String destFileName = destFile.toString(); JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); return destFileName; }
/** * Fills a report and saves it directly into a HTML file. * The intermediate JasperPrint object is not saved on disk. */ public static String runReportToHtmlFile( String sourceFileName, Map parameters, Connection conn ) throws JRException { File sourceFile = new File(sourceFileName); /* */ JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); parameters = JasperFillManager.setFileResolver(sourceFile, parameters); /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); /* */ File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".html"); String destFileName = destFile.toString(); JasperExportManager.exportReportToHtmlFile(jasperPrint, destFileName); return destFileName; }
/** * Fills a report and saves it directly into a HTML file. * The intermediate JasperPrint object is not saved on disk. * * @param sourceFileName the name of the compiled report file * @param parameters the parameters map * @return the name of the generated HTML file * @throws JRException * @see net.sf.jasperreports.engine.fill.JRFiller#fillReport(JasperReport, Map) */ public static String runReportToHtmlFile( String sourceFileName, Map parameters ) throws JRException { File sourceFile = new File(sourceFileName); /* */ JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); parameters = JasperFillManager.setFileResolver(sourceFile, parameters); /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters); /* */ File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".html"); String destFileName = destFile.toString(); JasperExportManager.exportReportToHtmlFile(jasperPrint, destFileName); return destFileName; }
/** * Fills a report and saves it directly into a PDF file. * The intermediate JasperPrint object is not saved on disk. * * @param sourceFileName the name of the compiled report file * @param parameters the parameters map * @return the name of the generated PDF file * @throws JRException * @see net.sf.jasperreports.engine.fill.JRFiller#fillReport(JasperReport, Map) */ public static String runReportToPdfFile( String sourceFileName, Map parameters ) throws JRException { File sourceFile = new File(sourceFileName); /* */ JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); parameters = JasperFillManager.setFileResolver(sourceFile, parameters); /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters); /* */ File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf"); String destFileName = destFile.toString(); JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); return destFileName; }
protected void closeWorkbook(OutputStream os) throws JRException { if (sheet == null)//empty document { //creating an empty sheet so that write() doesn't fail workbook.createSheet(EMPTY_SHEET_NAME, Integer.MAX_VALUE); } try { workbook.write(); workbook.close(); } catch (IOException e) { throw new JRException("Error generating XLS report : " + jasperPrint.getName(), e); } catch (WriteException e) { throw new JRException("Error generating XLS report : " + jasperPrint.getName(), e); } }
throw new JRException("Error trying to export to output stream : " + jasperPrint.getName(), e);
createSheet(getSheetName(jasperPrint.getName()));
xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, jasperPrint.getName()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_pageWidth, jasperPrint.getPageWidth()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_pageHeight, jasperPrint.getPageHeight());
Paper paper = pageFormat.getPaper(); printJob.setJobName("JasperReports - " + jasperPrint.getName());