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


Java JasperRunManager类代码示例

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


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

示例1: runReport

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
@Override
public byte[] runReport() throws Exception {
	List<byte[]> byteList = generateReports();
	if (byteList.isEmpty()) {
		HashMap<String, String> parameterMap = new HashMap<String, String>();
		parameterMap.put("SUBREPORT_DIR", reportPath);
		parameterMap.put("directorName", ConfigurationProperties.getInstance().getPropertyValue(Property.labDirectorName));
		List<ErrorMessages> errorMsgs = new ArrayList<ErrorMessages>();
		ErrorMessages msgs = new ErrorMessages();
		msgs.setMsgLine1(StringUtil.getMessageForKey("report.error.message.noPrintableItems"));
		errorMsgs.add(msgs);
		return JasperRunManager.runReportToPdf(reportPath + "NoticeOfReportError.jasper", parameterMap, new JRBeanCollectionDataSource(
				errorMsgs));
	} else {
		return merge(byteList);
	}
}
 
开发者ID:openelisglobal,项目名称:openelisglobal-sandbox,代码行数:18,代码来源:CollectionReport.java

示例2: generateHsfoRxPDF

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    InputStream is = Thread.currentThread().getContextClassLoader()
    .getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    return baos;
}
 
开发者ID:oscarservice,项目名称:oscar-old,代码行数:17,代码来源:FrmPDFServlet.java

示例3: generateHsfoRxPDF

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req) {

		HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession().getAttribute(HSFO_RX_DATA_KEY);

		JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
		InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		try {
			JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
		} catch (JRException e) {
			throw new RuntimeException(e);
		}
		return baos;
	}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:16,代码来源:FrmCustomedPDFServlet.java

示例4: generateHsfoRxPDF

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");
   
    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    finally {
    	IOUtils.closeQuietly(is);
    }
    
    return baos;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:21,代码来源:FrmPDFServlet.java

示例5: run

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
/**
 *
 */
public void run() throws JRException
{
	long start = System.currentTimeMillis();
	//Preparing parameters
	Image image = Toolkit.getDefaultToolkit().createImage("dukesign.jpg");
	MediaTracker traker = new MediaTracker(new Panel());
	traker.addImage(image, 0);
	try
	{
		traker.waitForID(0);
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
	
	Map<String, Object> parameters = new HashMap<String, Object>();
	parameters.put("ReportTitle", "The First Jasper Report Ever");
	parameters.put("MaxOrderID", new Integer(10500));
	parameters.put("SummaryImage", image);
	
	JasperRunManager.runReportToPdfFile("build/reports/FirstJasper.jasper", parameters, getDemoHsqldbConnection());
	System.err.println("PDF running time : " + (System.currentTimeMillis() - start));
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:28,代码来源:JasperApp.java

示例6: generateReportToOutputStream

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
/**
 * @see org.kuali.kfs.sys.batch.service.ReportGenerationService#generateReportToOutputStream(java.util.Map, java.lang.Object,
 *      java.lang.String, java.io.ByteArrayOutputStream)
 */
public void generateReportToOutputStream(Map<String, Object> reportData, Object dataSource, String template, ByteArrayOutputStream baos) {
    ClassPathResource resource = getReportTemplateClassPathResource(template.concat(ReportGeneration.DESIGN_FILE_EXTENSION));
    if (resource == null || !resource.exists()) {
        throw new IllegalArgumentException("Cannot find the template file: " + template.concat(ReportGeneration.DESIGN_FILE_EXTENSION));
    }

    try {
        if (reportData != null && reportData.containsKey(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME)) {
            Map<String, String> subReports = (Map<String, String>) reportData.get(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME);
            String subReportDirectory = (String) reportData.get(ReportGeneration.PARAMETER_NAME_SUBREPORT_DIR);
            compileSubReports(subReports, subReportDirectory);
        }

        String designTemplateName = template.concat(ReportGeneration.DESIGN_FILE_EXTENSION);
        InputStream jasperReport = new FileInputStream(compileReportTemplate(designTemplateName));

        JRDataSource jrDataSource = JasperReportsUtils.convertReportData(dataSource);

         JasperRunManager.runReportToPdfStream(jasperReport, baos, decorateReportData(reportData), jrDataSource);
    }
    catch (Exception e) {
        LOG.error(e);
        throw new RuntimeException("Fail to generate report.", e);
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:30,代码来源:ReportGenerationServiceImpl.java

示例7: generateReportToPdfFile

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
/**
 * The dataSource can be an instance of JRDataSource, java.util.Collection or object array.
 * 
 * @see org.kuali.ole.sys.batch.service.ReportGenerationService#generateReportToPdfFile(java.util.Map, java.lang.Object, java.lang.String,
 *      java.lang.String)
 */
public void generateReportToPdfFile(Map<String, Object> reportData, Object dataSource, String template, String reportFileName) {
    ClassPathResource resource = getReportTemplateClassPathResource(template);
    if (resource == null || !resource.exists()) {
        throw new IllegalArgumentException("Cannot find the template file: " + template);
    }

    try {
        if (reportData != null && reportData.containsKey(PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME)) {
            Map<String, String> subReports = (Map<String, String>) reportData.get(PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME);
            String subReportDirectory = (String) reportData.get(PARAMETER_NAME_SUBREPORT_DIR);
            compileSubReports(subReports, subReportDirectory);
        }

        String realTemplateNameWithoutExtension = removeTemplateExtension(resource);
        String designTemplateName = realTemplateNameWithoutExtension.concat(DESIGN_FILE_EXTENSION);
        String jasperReportName = realTemplateNameWithoutExtension.concat(JASPER_REPORT_EXTENSION);
        compileReportTemplate(designTemplateName, jasperReportName);

        JRDataSource jrDataSource = JasperReportsUtils.convertReportData(dataSource);

        reportFileName = reportFileName + PDF_FILE_EXTENSION;
        File reportDirectory = new File(StringUtils.substringBeforeLast(reportFileName, SEPARATOR));
        if(!reportDirectory.exists()) {
            reportDirectory.mkdir();
        }
        
        JasperRunManager.runReportToPdfFile(jasperReportName, reportFileName, reportData, jrDataSource);
    }
    catch (Exception e) {
        LOG.error(e);
        throw new RuntimeException("Fail to generate report.", e);
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:40,代码来源:ReportGenerationServiceImpl.java

示例8: generateReportToOutputStream

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
/**
 * @see org.kuali.ole.sys.batch.service.ReportGenerationService#generateReportToOutputStream(java.util.Map, java.lang.Object,
 *      java.lang.String, java.io.ByteArrayOutputStream)
 */
public void generateReportToOutputStream(Map<String, Object> reportData, Object dataSource, String template, ByteArrayOutputStream baos) {
    ClassPathResource resource = getReportTemplateClassPathResource(template);
    if (resource == null || !resource.exists()) {
        throw new IllegalArgumentException("Cannot find the template file: " + template);
    }

    try {
        if (reportData != null && reportData.containsKey(PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME)) {
            Map<String, String> subReports = (Map<String, String>) reportData.get(PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME);
            String subReportDirectory = (String) reportData.get(PARAMETER_NAME_SUBREPORT_DIR);
            compileSubReports(subReports, subReportDirectory);
        }

        String realTemplateNameWithoutExtension = removeTemplateExtension(resource);
        String designTemplateName = realTemplateNameWithoutExtension.concat(DESIGN_FILE_EXTENSION);
        String jasperReportName = realTemplateNameWithoutExtension.concat(JASPER_REPORT_EXTENSION);
        compileReportTemplate(designTemplateName, jasperReportName);

        JRDataSource jrDataSource = JasperReportsUtils.convertReportData(dataSource);

        InputStream inputStream = new FileInputStream(jasperReportName);

        JasperRunManager.runReportToPdfStream(inputStream, (OutputStream) baos, reportData, jrDataSource);
    }
    catch (Exception e) {
        LOG.error(e);
        throw new RuntimeException("Fail to generate report.", e);
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:34,代码来源:ReportGenerationServiceImpl.java

示例9: generateReportToPdfFile

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
/**
 * The dataSource can be an instance of JRDataSource, java.util.Collection or object array.
 * 
 * @see org.kuali.kfs.sys.batch.service.ReportGenerationService#generateReportToPdfFile(java.util.Map, java.lang.Object, java.lang.String,
 *      java.lang.String)
 */
public void generateReportToPdfFile(Map<String, Object> reportData, Object dataSource, String template, String reportFileName) {
    ClassPathResource resource = getReportTemplateClassPathResource(template.concat(ReportGeneration.DESIGN_FILE_EXTENSION));
    if (resource == null || !resource.exists()) {
        throw new IllegalArgumentException("Cannot find the template file: " + template.concat(ReportGeneration.DESIGN_FILE_EXTENSION));
    }

    try {
        if (reportData != null && reportData.containsKey(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME)) {
            Map<String, String> subReports = (Map<String, String>) reportData.get(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME);
            String subReportDirectory = (String) reportData.get(ReportGeneration.PARAMETER_NAME_SUBREPORT_DIR);
            compileSubReports(subReports, subReportDirectory);
        }

        String designTemplateName = template.concat(ReportGeneration.DESIGN_FILE_EXTENSION);
        InputStream jasperReport = new FileInputStream(compileReportTemplate(designTemplateName));

        JRDataSource jrDataSource = JasperReportsUtils.convertReportData(dataSource);

        reportFileName = reportFileName + ReportGeneration.PDF_FILE_EXTENSION;
        File reportDirectory = new File(StringUtils.substringBeforeLast(reportFileName, File.separator));
        if(!reportDirectory.exists()) {
            reportDirectory.mkdir();
        }

        JasperRunManager.runReportToPdfStream(jasperReport, new FileOutputStream(reportFileName), decorateReportData(reportData), jrDataSource);
    }
    catch (Exception e) {
        LOG.error(e);
        throw new RuntimeException("Fail to generate report.", e);
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:38,代码来源:ReportGenerationServiceImpl.java

示例10: handleRequest

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView mv = null;

    Integer pid = -1;
    try {
        pid = Integer.parseInt(request.getParameter("pid"));
    } catch (Exception ex) {
        pid = -1;
    }
    if (pid.equals(-1)) {
        return new ModelAndView("/error/wproblem");
    }

    try {

        jasperReport = JasperCompileManager.compileReport(Config.getProperty("problems.report.path") + "Problem.jrxml");

        Map<String, String> parametros = new HashMap<String, String>();

        parametros.put("PID", String.valueOf(pid));
        /*
         * try { jasperPrint = JasperFillManager.fillReport(jasperReport,
         * parametros, ds.getConnection()); } catch (SQLException ex) {
         * logger.error("Error generando Reporte."); ex.printStackTrace(); }
         *
         *
         * JasperExportManager.exportReportToPdfFile(jasperPrint,
         * "reporte.pdf");
         */

        //
        byte[] reporte = null;
        Connection conn = dataSource.getConnection();
        reporte = JasperRunManager.runReportToPdf(jasperReport, parametros, conn);

        response.setContentType("application/pdf");
        response.setHeader("Content-disposition", "inline; filename=" + pid + ".pdf");
        response.setHeader("Cache-Control", "max-age=30");
        response.setHeader("Pragma", "No-cache");
        response.setDateHeader("Expires", 0);
        response.setContentLength(reporte.length);

        ServletOutputStream out = response.getOutputStream();
        out.write(reporte, 0, reporte.length);
        out.flush();
        out.close();
        //
        conn.close();
        return new ModelAndView("index");

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
    return mv;
}
 
开发者ID:dovier,项目名称:coj-web,代码行数:56,代码来源:problemPDFController.java

示例11: performAction

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse response) throws Exception {
	
	//no forward necessary if successful, returning stream
	String forward = FWD_FAIL;
	
	ActionError error = null;
	ActionMessages errors = new ActionMessages();
	
	BaseActionForm dynaForm = (BaseActionForm) form;
	
	request.getSession().setAttribute(SAVE_DISABLED, "true");
			
	String workplanType = dynaForm.getString("workplanType");
	String workplanName;
	
	if (workplanType.equals("test") ){
		String testID = (String)dynaForm.get("testTypeID");
		workplanName = getTestTypeName(testID);
	}else {
		workplanType = Character.toUpperCase(workplanType.charAt(0))+ workplanType.substring(1);
		workplanName = dynaForm.getString("testName");
	}
	

	//get workplan report based on testName
	workplanReport = getWorkplanReport(workplanType, workplanName);
			
	//set jasper report parameters
	HashMap<String, ?> parameterMap = workplanReport.getParameters();
					
	//prepare report
	List<?> workplanRows = workplanReport.prepareRows(dynaForm);
			
	//set Jasper report file name
	String reportFileName = workplanReport.getFileName();
	String reportFile = this.getServlet().getServletConfig().getServletContext().getRealPath("WEB-INF/reports/" + reportFileName + ".jasper");
					
    try {
        	
        byte[] bytes = null;
		 
		JRDataSource dataSource = createReportDataSource(workplanRows);
		bytes = JasperRunManager.runReportToPdf(reportFile, parameterMap, dataSource);
			
		ServletOutputStream servletOutputStream = response.getOutputStream();
		response.setContentType("application/pdf");
		response.setContentLength(bytes.length);

		servletOutputStream.write(bytes, 0, bytes.length);
		servletOutputStream.flush();
		servletOutputStream.close();	

    }
    catch (JRException jre) {
    	LogEvent.logError("PringWorkplanReportAction","processRequest()", jre.toString());
    	error = new ActionError("error.jasper", null, null);
    } catch (Exception e) {
    	LogEvent.logError("PrintWorkplanReportAction","processRequest()", e.toString());
    	error = new ActionError("error.jasper", null, null);
    }
    
    if (error != null) {
		errors.add(ActionMessages.GLOBAL_MESSAGE, error);
		request.setAttribute(Globals.ERROR_KEY, errors);
		forward = FWD_FAIL;
     	}
    
    return mapping.findForward(forward);
	
}
 
开发者ID:openelisglobal,项目名称:openelisglobal-sandbox,代码行数:71,代码来源:PrintWorkplanReportAction.java

示例12: runReport

import net.sf.jasperreports.engine.JasperRunManager; //导入依赖的package包/类
/**
 * Nearly every report does PDF this routine does that, but some do other things like export to CSV which involves messing with the response and the headers
 * @param response response, so that appropriate things can be set into it.
 * @param fullReportFilename - valid full path to write the report
 * @throws JRException
 * @throws IllegalStateException
 * @see us.mn.state.health.lims.reports.action.implementation.IReportCreator#runReport(java.lang.String, Response)
 */
@Override
public byte[] runReport( ) throws Exception {
    return JasperRunManager.runReportToPdf(fullReportFilename, getReportParameters(), getReportDataSource()); 
}
 
开发者ID:openelisglobal,项目名称:openelisglobal-sandbox,代码行数:13,代码来源:Report.java


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