當前位置: 首頁>>代碼示例>>Java>>正文


Java JasperExportManager類代碼示例

本文整理匯總了Java中net.sf.jasperreports.engine.JasperExportManager的典型用法代碼示例。如果您正苦於以下問題:Java JasperExportManager類的具體用法?Java JasperExportManager怎麽用?Java JasperExportManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JasperExportManager類屬於net.sf.jasperreports.engine包,在下文中一共展示了JasperExportManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generatePDF

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
public PDFResponseModel generatePDF(String fileName, String template, String bucketName,
    Collection<?> items, Map<String, Object> parameters)
    throws ClassNotFoundException, JRException, IOException {

  JasperPrint jasperPrint;
  InputStream inputStream = null;

  JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(items);

  try {
    inputStream = storageUtil.getInputStream(bucketName, template);
    jasperPrint = JasperFillManager.fillReport(JasperCompileManager.compileReport(
        inputStream), parameters, beanColDataSource);
    byte[] pdfBytes = JasperExportManager.exportReportToPdf(jasperPrint);
    return new PDFResponseModel(fileName, pdfBytes);
  } catch (ClassNotFoundException | JRException | IOException e) {
    xLogger.severe("Failed to generate PDF for file name - ", fileName, e);
    throw e;
  } finally {
    if (inputStream != null) {
      inputStream.close();
    }
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:25,代碼來源:JasperClient.java

示例2: testInvoice

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
@Test
public void testInvoice(){
  List<InvoiceItem> invoiceItems = new ArrayList<>();

  int count = 1;
  for (IDemandItem demandItem : getDemandItems()) {
    InvoiceItem invoiceItem = new InvoiceItem();
    invoiceItem.setItem(demandItem.getMaterialId().toString());
    invoiceItem.setQuantity(demandItem.getQuantity().toString());
    invoiceItem.setRecommended(demandItem.getRecommendedOrderQuantity().toString());
    invoiceItem.setRemarks("Blah");
      invoiceItem.setBatchId("AB/1234/56"+count);
      invoiceItem.setExpiry("11/03/2020");
      invoiceItem.setManufacturer("Serum");
      invoiceItem.setBatchQuantity(BigDecimal.TEN.toPlainString());
    invoiceItem.setSno(String.valueOf(count++));
    invoiceItems.add(invoiceItem);
  }

  JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(invoiceItems);

  try {

    Map<String, Object> hm = new HashMap<>();
    JasperPrint jasperPrint = JasperFillManager.fillReport(
        JasperCompileManager
            .compileReport(Thread.currentThread().getContextClassLoader().getResourceAsStream(
                "test_logistimo_invoice.jrxml")), hm, beanColDataSource);

    JasperExportManager.exportReportToPdfFile(jasperPrint, "/tmp/logistimo_invoice.pdf");


  } catch (Exception e) {
    e.printStackTrace();
  }


}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:39,代碼來源:GenerateInvoiceTest.java

示例3: saveReport

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 * Saves a pre-compiled report into a file.
 * 
 * @param jasperPrint
 *          JasperPrint object which contains a compiled report.
 * @param expType
 *          The desired output type of the report.
 * @param exportParameters
 *          Export parameters than can be added to configure the resulting report.
 * @param target
 *          The file used to return the report.
 * @throws JRException
 *           In case there is any error saving the report an exception is thrown with the error
 *           message.
 */
public static void saveReport(JasperPrint jasperPrint, ExportType expType,
    Map<Object, Object> exportParameters, File target) throws JRException {
  switch (expType) {
  case CSV:
    saveCsvReportToFile(jasperPrint, target);
    break;
  case HTML:
    if (log.isDebugEnabled())
      log.debug("JR: Print HTML");
    saveHTMLReportToFile(jasperPrint, exportParameters, target);
    break;
  case PDF:
    JasperExportManager.exportReportToPdfFile(jasperPrint, target.getAbsolutePath());
    break;
  case TXT:
    saveTxtReportToFile(jasperPrint, target);
    break;
  case XLS:
    saveExcelReportToFile(jasperPrint, exportParameters, target);
    break;
  case XML:
    JasperExportManager.exportReportToXmlFile(jasperPrint, target.getAbsolutePath(), true);
    break;
  }
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:41,代碼來源:ReportingUtils.java

示例4: gerarDanfe

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
private static void gerarDanfe(String url, List<String> emit, List<String> dest, List<String> nota, JRDataSource itens, String qrcode){
    try {
        // Teste
        //String compilado = System.getProperty("user.dir") + "/danfe_nfce_80.jasper";;
        String output = "danfe.pdf"; 
        map.put("emit", emit);
        map.put("dest", dest);
        map.put("nota", nota);
        map.put("qrcode", qrcode);
        // Relatório compilado
        JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
        //InputStream jasperStream = getClass().getResourceAsStream("/Foo.jasper");
        //JasperReport report = (JasperReport) JRLoader.loadObject(jasperStream);
        // Relatório nao compilado
        //JasperReport report = JasperCompileManager.compileReport(jrxml);
        JasperPrint print = JasperFillManager.fillReport(report, map, itens);
        JasperExportManager.exportReportToPdfFile(print, output);
    } catch (JRException e) {
        System.out.println("erro: "+e.getMessage());
    }
}
 
開發者ID:juniortada,項目名稱:Java-Danfe,代碼行數:22,代碼來源:DanfeNfe.java

示例5: pdf

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 *
 */
public void pdf() throws JRException
{
	File[] files = getFiles(new File("build/reports"), "jrprint");
	for(int i = 0; i < files.length; i++)
	{
		File reportFile = files[i];
		long start = System.currentTimeMillis();
		String fileName = reportFile.getAbsolutePath();
		JasperExportManager.exportReportToPdfFile(
			fileName, 
			fileName.substring(0, fileName.indexOf(".jrprint")) + ".pdf"
			);
		System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:19,代碼來源:ExcelDataAdapterApp.java

示例6: gerarDanfeNfse

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
private static void gerarDanfeNfse(String url, List<String> emit, List<String> dest, List<String> ser, List<String> nota, String xml, String logo) {
    try {
        // Teste
        //String compilado = System.getProperty("user.dir") + "/danfe_nfce_80.jasper";;
        String output = "danfe.pdf"; 
        map.put("emit", emit);
        map.put("dest", dest);
        map.put("ser", ser);
        map.put("nota", nota);
        map.put("logo", logo);
        // brasao
        String brasao = Paths.get(System.getProperty("user.dir"), "danfe","brasao.png").toAbsolutePath().toString();
        map.put("brasao", brasao);
        // JrDataSource
        JRDataSource jr = new JRXmlDataSource(xml);
        // Relatório compilado
        JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
        JasperPrint print = JasperFillManager.fillReport(report, map, jr);
        JasperExportManager.exportReportToPdfFile(print, output);
    } catch (JRException e) {
        System.out.println("erro: "+e.getMessage());
    }
}
 
開發者ID:juniortada,項目名稱:Java-Danfe,代碼行數:24,代碼來源:DanfeNfe.java

示例7: emitir

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
@Override
public void emitir() throws JRException {
	try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) {
		JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection);
		this.relatorioGerado = print.getPages().size() > 0;
		
		if(this.isRelatorioGerado()) {
			String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome());
			servletResponse.setHeader("Content-Disposition", attachment);
			JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream());		
		}
	} catch (IOException e) {
		throw new RelatorioNaoExisteException(relatorio, e);
	}
}
 
開發者ID:marcelothebuilder,項目名稱:webpedidos,代碼行數:16,代碼來源:EmissorRelatorioServlet.java

示例8: html

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 *
 */
public void html() throws JRException
{
	long start = System.currentTimeMillis();
	JasperExportManager.exportReportToHtmlFile("build/reports/XChartReport.jrprint");
	System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:10,代碼來源:XChartApp.java

示例9: html

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 *
 */
public void html() throws JRException
{
	long start = System.currentTimeMillis();
	JasperExportManager.exportReportToHtmlFile("build/reports/FirstJasper.jrprint");
	System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:10,代碼來源:JasperApp.java

示例10: xml

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 *
 */
public void xml() throws JRException
{
	long start = System.currentTimeMillis();
	JasperExportManager.exportReportToXmlFile("build/reports/LandscapeReport.jrprint", false);
	System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:10,代碼來源:LandscapeApp.java

示例11: html

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 *
 */
public void html() throws JRException
{
	long start = System.currentTimeMillis();
	JasperExportManager.exportReportToHtmlFile("build/reports/JFreeChartReport.jrprint");
	System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:10,代碼來源:JFreeChartApp.java

示例12: xml

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 *
 */
public void xml() throws JRException
{
	long start = System.currentTimeMillis();
	JasperExportManager.exportReportToXmlFile("build/reports/UnicodeReport.jrprint", false);
	System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:10,代碼來源:UnicodeApp.java

示例13: pdf

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 *
 */
public void pdf() throws JRException
{
	File[] files = getFiles(new File("build/reports"), "jrprint");
	for(int i = 0; i < files.length; i++)
	{
		File reportFile = files[i];
		long start = System.currentTimeMillis();
		JasperExportManager.exportReportToPdfFile(reportFile.getAbsolutePath());
		System.err.println("Report : " + reportFile + ". PDF export time : " + (System.currentTimeMillis() - start));
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:15,代碼來源:JsonQLDataSourceApp.java

示例14: html

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 *
 */
public void html() throws JRException
{
	long start = System.currentTimeMillis();
	JasperExportManager.exportReportToHtmlFile("build/reports/UnicodeReport.jrprint");
	System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:10,代碼來源:UnicodeApp.java

示例15: xml

import net.sf.jasperreports.engine.JasperExportManager; //導入依賴的package包/類
/**
 *
 */
public void xml() throws JRException
{
	long start = System.currentTimeMillis();
	JasperExportManager.exportReportToXmlFile("build/reports/BookReport.jrprint", false);
	System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:10,代碼來源:BookApp.java


注:本文中的net.sf.jasperreports.engine.JasperExportManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。