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


Java JRException类代码示例

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


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

示例1: xls

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

示例2: generatePDF

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

示例3: export

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
	String fileName=this.getExportFileName(req);
	fileName+=".xls";
	res.setContentType("application/octet-stream");
	res.setHeader("Connection", "close");
	res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
	JRXlsExporter exporter = new JRXlsExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:XlsExporter.java

示例4: export

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
public void export(HttpServletRequest req, HttpServletResponse res)
		throws Exception {
	res.setContentType("text/xml");
	res.setHeader("Content-Disposition", "inline; filename=\"file.jrpxml\"");
	JRXmlExporter exporter = new JRXmlExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	//exporter.setParameter(JRExporterParameter.START_PAGE_INDEX, Integer.valueOf(1));
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:22,代码来源:JrpxmlExporter.java

示例5: export

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
	String fileName=this.getExportFileName(req);
	fileName+=".rtf";
	res.setContentType("application/octet-stream");
	res.setHeader("Connection", "close");
	res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
	JRRtfExporter exporter = new JRRtfExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:RtfExporter.java

示例6: export

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
	res.setContentType("text/html;charset=UTF-8");
	JRHtmlExporter exporter=new JRHtmlExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	req.getSession().setAttribute(BaseHttpServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	String path=req.getContextPath();
	if(path.endsWith("/")){
		path+="dorado/bdf2/jasperreports/html.image";
	}else{
		path+="/dorado/bdf2/jasperreports/html.image";			
	}
	exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,path+"?image=");
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:27,代码来源:HtmlExporter.java

示例7: export

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
	String fileName=this.getExportFileName(req);
	fileName+=".pptx";
	res.setContentType("application/octet-stream");
	res.setHeader("Connection", "close");
	res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
	JRPptxExporter exporter = new JRPptxExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:PptxExporter.java

示例8: export

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
	String fileName=this.getExportFileName(req);
	fileName+=".pdf";
	res.setContentType("application/octet-stream");
	res.setHeader("Connection", "close");
	res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
	JRPdfExporter exporter = new JRPdfExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:PdfExporter.java

示例9: export

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
	String fileName=this.getExportFileName(req);
	fileName+=".csv";
	res.setContentType("application/octet-stream");
	res.setHeader("Connection", "close");
	res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
	JRCsvExporter exporter = new JRCsvExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:CsvExporter.java

示例10: export

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
	String fileName=this.getExportFileName(req);
	fileName+=".docx";
	res.setContentType("application/octet-stream");
	res.setHeader("Connection", "close");
	res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
	JRDocxExporter exporter = new JRDocxExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:DocxExporter.java

示例11: saveHTMLReportToFile

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
/**
 * Generates an HTML report from a pre-compiled report and returns it into a file.
 * 
 * @param jasperPrint
 *          JasperPrint object which contains a compiled report.
 * @param exportParameters
 *          Export parameters than can be added to configure the resulting report.
 * @param file
 *          The file used to return the report.
 * @throws JRException
 *           In case there is any error generating the report an exception is thrown with the
 *           error message.
 */
private static void saveHTMLReportToFile(JasperPrint jasperPrint,
    Map<Object, Object> exportParameters, File file) throws JRException {
  final HtmlExporter htmlExporter = new HtmlExporter();
  SimpleExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
  SimpleHtmlExporterOutput exporterOutput = new SimpleHtmlExporterOutput(file);

  if (exportParameters != null && exportParameters.size() > 0) {
    SimpleHtmlReportConfiguration exportConfiguration = new SimpleHtmlReportConfiguration();
    setHtmlConfigurationFromExportParameters(exportParameters, exportConfiguration,
        exporterOutput);
    htmlExporter.setConfiguration(exportConfiguration);
  } else {
    SimpleHtmlReportConfiguration reportExportConfiguration = new SimpleHtmlReportConfiguration();
    reportExportConfiguration.setSizeUnit(HtmlSizeUnitEnum.POINT);
    htmlExporter.setConfiguration(reportExportConfiguration);
  }
  htmlExporter.setExporterInput(exporterInput);
  htmlExporter.setExporterOutput(exporterOutput);
  htmlExporter.exportReport();
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:34,代码来源:ReportingUtils.java

示例12: xls

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/Barcode4JReport.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));
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:25,代码来源:Barcode4JApp.java

示例13: openReport

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
/**
 * Abre um relatório usando um datasource genérico.
 *
 * @param titulo Título usado na janela do relatório.
 * @param inputStream InputStream que contém o relatório.
 * @param parametros Parâmetros utilizados pelo relatório.
 * @param dataSource Datasource a ser utilizado pelo relatório.
 * @throws JRException Caso ocorra algum problema na execução do relatório
 */
public static void openReport(
        String titulo,
        InputStream inputStream,
        Map parametros,
        JRDataSource dataSource ) throws JRException {
 
    /*
     * Cria um JasperPrint, que é a versão preenchida do relatório,
     * usando um datasource genérico.
     */
    JasperPrint print = JasperFillManager.fillReport(
            inputStream, parametros, dataSource );
 
    // abre o JasperPrint em um JFrame
    viewReportFrame( titulo, print );
 
}
 
开发者ID:iuryamicussi,项目名称:TrabalhoCrisParte2,代码行数:27,代码来源:ReportUtils.java

示例14: loadReport

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

示例15: imprimirPoliza

import net.sf.jasperreports.engine.JRException; //导入依赖的package包/类
public Blob imprimirPoliza() throws JRException, IOException {

		List<Object> objectsReport = new ArrayList<Object>();

		PolizaRCPReporte polizaRCPReporte = new PolizaRCPReporte();
		polizaRCPReporte.setPolizaCliente(getPolizaCliente().toString());
		polizaRCPReporte.setPolizaNumero(getPolizaNumero());
		polizaRCPReporte.setPolizaCompania(getPolizaCompania().getCompaniaNombre());
		polizaRCPReporte.setPolizaFechaEmision(getPolizaFechaEmision());
		polizaRCPReporte.setPolizaFechaVigencia(getPolizaFechaVigencia());
		polizaRCPReporte.setPolizaFechaVencimiento(getPolizaFechaVencimiento());
		polizaRCPReporte.setRiesgoRCPMonto(getRiesgoRCPMonto());
		polizaRCPReporte.setPolizaImporteTotal(getPolizaImporteTotal());
		polizaRCPReporte.setPolizaEstado(getPolizaEstado().toString());

		objectsReport.add(polizaRCPReporte);
		String jrxml = "PolizaRCP.jrxml";
		String nombreArchivo = "PolizaRCP_" + getPolizaCliente().toString().replaceAll("\\s", "_") + "_"
				+ getPolizaNumero();

		return ReporteRepository.imprimirReporteIndividual(objectsReport, jrxml, nombreArchivo);
	}
 
开发者ID:leandrogonqn,项目名称:Proyecto2017Seguros,代码行数:23,代码来源:PolizaRCP.java


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