当前位置: 首页>>代码示例>>Java>>正文


Java JasperCompileManager类代码示例

本文整理汇总了Java中net.sf.jasperreports.engine.JasperCompileManager的典型用法代码示例。如果您正苦于以下问题:Java JasperCompileManager类的具体用法?Java JasperCompileManager怎么用?Java JasperCompileManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JasperCompileManager类属于net.sf.jasperreports.engine包,在下文中一共展示了JasperCompileManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generatePDF

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的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: gerarRelatorioClientesSintetico

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
@Override
public JasperViewer gerarRelatorioClientesSintetico() {

    Connection connection = PostgreSQLDAOFactory.getConnection();

    try {
        Statement stm = connection.createStatement();
        String query = "SELECT\n"
                + "     cl.\"cod_cliente\" AS codigo,\n"
                + "     cl.\"nome_cliente\" AS nome,\n"
                + "     ci.\"nome_cidade\" AS nome_cidade,\n"
                + "     ci.\"sigla_uf\" AS sigla,\n"
                + "     cl.\"telefone\" AS telefone\n"
                + "FROM\n"
                + "     \"cliente\" cl INNER JOIN \"cidade\" ci "
                + "ON cl.\"cod_cidade\" = ci.\"cod_cidade\"\n"
                + "ORDER BY\n"
                + "     cl.nome_cliente ASC";

        ResultSet rs = stm.executeQuery(query);

        JRResultSetDataSource jrRS = new JRResultSetDataSource(rs);

        InputStream fonte
                = PgRelatorioDAO.class.getResourceAsStream(
                        "/br/com/pitanga/report/RelatorioClientesSintetico.jrxml");

        JasperReport report = JasperCompileManager.compileReport(fonte);

        JasperPrint print = JasperFillManager.fillReport(report, null, jrRS);
        JasperViewer jv = new JasperViewer(print, false);

        return jv;

    } catch (JRException | SQLException ex) {
        throw new DAOException(
                "Falha ao gerar relatório sintético "
                + "de clientes em JDBCRelatorioDAO", ex);
    }
}
 
开发者ID:douglasgusson,项目名称:pitanga-system,代码行数:41,代码来源:PgRelatorioDAO.java

示例3: generate

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
public void generate(String reportURL,Collection<Articulo> articulos)
{
    try {
        InputStream is = loadReport(reportURL);
        JasperDesign design = JRXmlLoader.load(is);
        JasperReport report = JasperCompileManager.compileReport(design);
        jp = JasperFillManager.fillReport(report,new HashMap(),new JRBeanCollectionDataSource(articulos));

        JasperViewer jasperViewer = new JasperViewer(jp, false);
        jasperViewer.setDefaultCloseOperation(JasperViewer.DISPOSE_ON_CLOSE);
        jasperViewer.setTitle("Etiquetas");
        jasperViewer.setZoomRatio((float) 1.25);
        jasperViewer.setExtendedState(JasperViewer.MAXIMIZED_BOTH);
        jasperViewer.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
        jasperViewer.requestFocus();
        jasperViewer.setVisible(true);
    }catch (Exception e) {
        logger.error("Error al generar etiquetas", e);
    }

}
 
开发者ID:ZooMMX,项目名称:Omoikane,代码行数:22,代码来源:EtiquetaGenerator.java

示例4: compileReport

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:23,代码来源:AbstractTest.java

示例5: compileReportToJasperFile

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
/**
 * jasperreport compile jrxml 成 jasper
 * 
 * @param sourceFile		如: File[]
 * @param destDir			如: C:/report/     產生一個 test.jasper 到 C:/report/ 中
 * @return
 * @throws JRException
 */
public static String compileReportToJasperFile(File sourceFile[], String destDir) throws JRException {
	String jasperFirst = "";
	for (int ix=0; sourceFile!=null && ix<sourceFile.length; ix++) {
		File srcFile = sourceFile[ix];
		if (!srcFile.exists() || srcFile.getName().indexOf(".jrxml")==-1) {
			srcFile=null;
			continue;
		}
		//String destFileName=srcFile.getName().replaceAll(".jrxml", ".jasper");
		String destFileName=srcFile.getPath().replaceAll(".jrxml", ".jasper");
		if ("".equals(jasperFirst)) {
			jasperFirst = destFileName;
		}
		JasperCompileManager.compileReportToFile(srcFile.getPath(), destFileName);
		logger.info("out process : " + destFileName);
	}
	return jasperFirst;
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:27,代码来源:JReportUtils.java

示例6: loadReport

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
public void loadReport(String reportName, ReportObject reportObject) {

		logging = LoggingEngine.getInstance();
		
		try {
			
			final InputStream inputStream = ShowReport.class
					.getResourceAsStream("/com/coder/hms/reportTemplates/" + reportName + ".jrxml");
			JasperReport report = JasperCompileManager.compileReport(inputStream);

			HashMap<String, Object> parameters = new HashMap<String, Object>();	
			List<ReportObject> list = new ArrayList<ReportObject>();
			list.add(reportObject);
			JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(list);
			JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, beanColDataSource);
			final JRViewer viewer = new JRViewer(jasperPrint);

			setType(Type.POPUP);
			setResizable(false);
			setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
			this.setTitle("Reservation [Report]");
			this.setExtendedState(Frame.MAXIMIZED_BOTH);
			this.setAlwaysOnTop(isAlwaysOnTopSupported());
			this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			getContentPane().setLayout(new BorderLayout());
			this.setIconImage(Toolkit.getDefaultToolkit().
					getImage(LoginWindow.class.getResource(LOGOPATH)));
			this.setResizable(false);
			getContentPane().add(viewer, BorderLayout.CENTER);

		} catch (JRException e) {
			logging.setMessage("JRException report error!");
		}

	}
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:36,代码来源:ShowReport.java

示例7: testInvoice

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的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

示例8: loadEvaluator

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
protected void loadEvaluator(JasperReport jasperReport)
{
	try
	{
		JREvaluator evaluator = JasperCompileManager.getInstance(filler.getJasperReportsContext()).getEvaluator(jasperReport, parentCrosstab);
		crosstabEvaluator = new JRCrosstabExpressionEvaluator(evaluator);
	}
	catch (JRException e)
	{
		throw 
			new JRRuntimeException(
				EXCEPTION_MESSAGE_KEY_EVALUATOR_LOADING_ERROR,
				(Object[])null,
				e);
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:17,代码来源:JRFillCrosstab.java

示例9: compileReport

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
protected void compileReport() throws JRException, IOException
{
	InputStream jrxmlInput = JRLoader.getResourceInputStream(jrxml);
	JasperDesign design;
	try
	{
		design = JRXmlLoader.load(jrxmlInput);
	}
	finally
	{
		jrxmlInput.close();
	}
	
	report = JasperCompileManager.compileReport(design);
	
	fillManager = JasperFillManager.getInstance(jasperReportsContext);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:18,代码来源:Report.java

示例10: loadDefinitions

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
/**
 * Load the report definitions.
 */
@Override
public void loadDefinitions() {

    jasperReports = new HashMap<String, JasperReport>();

    for (Reporting report : ReportingDao.getReportingAsList()) {
        File reportFile = getReportPath(report);
        if (reportFile != null && reportFile.exists()) {
            try {
                JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
                JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
                jasperReports.put(report.template, jasperReport);
                if (log.isDebugEnabled()) {
                    log.debug("the jasper report " + report.template + " has been loaded");
                }
            } catch (Exception e) {
                log.error("Error while loading the report " + report.template, e.getMessage());
            }

        } else {
            log.error("Jasper report " + report.template + " not found !");
        }
    }

}
 
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:29,代码来源:ReportingUtilsImpl.java

示例11: compileQueryReport

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
/**
 * Compilez raportul pentru query
 */
public static void compileQueryReport() {
   String subreportFolder,subreportPath;
   String compiledSubFolder, compiledSubPath;

    //Subreport
    subreportFolder = ReadOnlyConfiguration.getString("JASPER_TEMPLATE_FOLDER");
    subreportPath = subreportFolder+ReadOnlyConfiguration.getString("JASPER_TEMPLATE_SUB_QUERY");
    compiledSubFolder = ReadOnlyConfiguration.getString("JASPER_COMPILED_FOLDER");
    compiledSubPath = compiledSubFolder+ReadOnlyConfiguration.getString("JASPER_COMPILED_SUB_QUERY");

    //Compilez si populez subreportul
    try
    {
        JasperCompileManager.compileReportToFile(
                subreportPath,
                compiledSubPath);
    }
    catch (JRException ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:genomeartist,项目名称:genomeartist,代码行数:26,代码来源:ResultReportTestReport.java

示例12: compileMapping

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
/**
 * Compilez raportul Mapare
 */
public static void compileMapping() {
   String subreportFolder,subreportPath;
   String compiledSubFolder, compiledSubPath;

    //Subreport
    subreportFolder = ReadOnlyConfiguration.getString("JASPER_TEMPLATE_FOLDER");
    subreportPath = subreportFolder+ReadOnlyConfiguration.getString("JASPER_TEMPLATE_SUB_MAPPING");
    compiledSubFolder = ReadOnlyConfiguration.getString("JASPER_COMPILED_FOLDER");
    compiledSubPath = compiledSubFolder+ReadOnlyConfiguration.getString("JASPER_COMPILED_SUB_MAPPING");

    //Compilez si populez subreportul
    try
    {
        JasperCompileManager.compileReportToFile(
                subreportPath,
                compiledSubPath);
    }
    catch (JRException ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:genomeartist,项目名称:genomeartist,代码行数:26,代码来源:ResultReportTestReport.java

示例13: compileSmithReport

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
/**
 * Compilez raportul Smith-Waterman
 */
public static void compileSmithReport() {
   String subreportFolder,subreportPath;
   String compiledSubFolder, compiledSubPath;

    //Subreport
    subreportFolder = ReadOnlyConfiguration.getString("JASPER_TEMPLATE_FOLDER");
    subreportPath = subreportFolder+ReadOnlyConfiguration.getString("JASPER_TEMPLATE_SUB_SMITH_WATERMAN");
    compiledSubFolder = ReadOnlyConfiguration.getString("JASPER_COMPILED_FOLDER");
    compiledSubPath = compiledSubFolder+ReadOnlyConfiguration.getString("JASPER_COMPILED_SUB_SMITH_WATERMAN");

    //Compilez si populez subreportul
    try
    {
        JasperCompileManager.compileReportToFile(
                subreportPath,
                compiledSubPath);
    }
    catch (JRException ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:genomeartist,项目名称:genomeartist,代码行数:26,代码来源:ResultReportTestReport.java

示例14: compilePositioning

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
/**
 * Compilez raportul Smith-Waterman
 */
public static void compilePositioning() {
   String subreportFolder,subreportPath;
   String compiledSubFolder, compiledSubPath;

    //Subreport
    subreportFolder = ReadOnlyConfiguration.getString("JASPER_TEMPLATE_FOLDER");
    subreportPath = subreportFolder+ReadOnlyConfiguration.getString("JASPER_TEMPLATE_SUB_POSITIONING");
    compiledSubFolder = ReadOnlyConfiguration.getString("JASPER_COMPILED_FOLDER");
    compiledSubPath = compiledSubFolder+ReadOnlyConfiguration.getString("JASPER_COMPILED_SUB_POSITIONING");

    //Compilez si populez subreportul
    try
    {
        JasperCompileManager.compileReportToFile(
                subreportPath,
                compiledSubPath);
    }
    catch (JRException ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:genomeartist,项目名称:genomeartist,代码行数:26,代码来源:ResultReportTestReport.java

示例15: compileGenes

import net.sf.jasperreports.engine.JasperCompileManager; //导入依赖的package包/类
/**
 * Compilez raportul Smith-Waterman
 */
public static void compileGenes() {
   String subreportFolder,subreportPath;
   String compiledSubFolder, compiledSubPath;

    //Subreport
    subreportFolder = ReadOnlyConfiguration.getString("JASPER_TEMPLATE_FOLDER");
    subreportPath = subreportFolder+ReadOnlyConfiguration.getString("JASPER_TEMPLATE_SUB_GENES");
    compiledSubFolder = ReadOnlyConfiguration.getString("JASPER_COMPILED_FOLDER");
    compiledSubPath = compiledSubFolder+ReadOnlyConfiguration.getString("JASPER_COMPILED_SUB_GENES");

    //Compilez si populez subreportul
    try
    {
        JasperCompileManager.compileReportToFile(
                subreportPath,
                compiledSubPath);
    }
    catch (JRException ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:genomeartist,项目名称:genomeartist,代码行数:26,代码来源:ResultReportTestReport.java


注:本文中的net.sf.jasperreports.engine.JasperCompileManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。