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


Java JRExporter.exportReport方法代码示例

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


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

示例1: exportReport

import net.sf.jasperreports.engine.JRExporter; //导入方法依赖的package包/类
/**
 * @throws JRException
 */
protected void exportReport(JRExporter exporter, JasperPrint jp, OutputStream os) throws JRException {
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);

    if (template.getJrExporterParameters() != null) {
        for (Entry<JRExporterParameter, Object> entry : template.getJrExporterParameters().entrySet()) {
            exporter.setParameter(entry.getKey(), entry.getValue());

        }
    }
    try {
        exporter.exportReport();

    } catch (JRException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:seedstack,项目名称:io-addon,代码行数:21,代码来源:JasperRenderer.java

示例2: execute

import net.sf.jasperreports.engine.JRExporter; //导入方法依赖的package包/类
@Override
public void execute(Connection connection) throws SQLException {
	InputStream relatorioStream = this.getClass().getResourceAsStream(this.caminhoRelatorio);

	try {
		JasperPrint print = JasperFillManager.fillReport(relatorioStream, this.parametros, connection);

		this.relatorioGerado = print.getPages().size() > 0;

		if (this.relatorioGerado) {
			JRExporter exportador = new JRPdfExporter();
			exportador.setParameter(JRExporterParameter.OUTPUT_STREAM, this.response.getOutputStream());
			exportador.setParameter(JRExporterParameter.JASPER_PRINT, print);

			this.response.setContentType("application/pdf");
			this.response
					.setHeader("Content-Disposition", "attachment; filename=\"" + this.nomeArquivoSaida + "\"");

			exportador.exportReport();
		}
	} catch (Exception e) {
		throw new SQLException("Erro ao executar relatorio " + this.caminhoRelatorio, e);
	}

}
 
开发者ID:fabiohxcx,项目名称:PedidoVenda,代码行数:26,代码来源:ExecutorRelatorio.java

示例3: printReport

import net.sf.jasperreports.engine.JRExporter; //导入方法依赖的package包/类
/**
 */
public static byte[] printReport(final File filejrxml, Map<String, Object> param, final Connection conn, String reportFormat)
		throws IOException, NamingException, SQLException, JRException {

	final JasperPrint jasperPrintTemp = getJasperPrint(filejrxml, param, conn);

	JasperPrintManager.printReport(jasperPrintTemp, false);
	JRExporter exporter = getJREXporter(reportFormat);

	ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, byteArrayOutputStream);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrintTemp);
	exporter.exportReport();

	return byteArrayOutputStream.toByteArray();
}
 
开发者ID:ldiaz,项目名称:laboratorioSpring,代码行数:19,代码来源:ReportJR.java

示例4: generateExcel

import net.sf.jasperreports.engine.JRExporter; //导入方法依赖的package包/类
@Override
public byte[] generateExcel(List<ExcelSheetReportData> excelSheetsReportData)
		throws Exception {

	if (excelSheetsReportData == null || excelSheetsReportData.size() == 0) {
		throw new Exception("There are no data to make report.");
	}

	String[] sheetNamesArray = new String[excelSheetsReportData.size()];
	List<JasperPrint> jasperPrints = new ArrayList<JasperPrint>();
	int i = 0;
	for (ExcelSheetReportData excelSheetReportData : excelSheetsReportData) {
		sheetNamesArray[i] = excelSheetReportData.getSheetName();
		i++;

		JRDataSource reportDataSource = new JRMapCollectionDataSource(
				excelSheetReportData.getSheetData());
		JasperPrint jasperPrint = null;
		if (excelSheetReportData.getSheetReportLocation() != null
				&& !excelSheetReportData.getSheetReportLocation()
						.equals("")) {
			jasperPrint = JasperFillManager.fillReport(
					excelSheetReportData.getSheetReportLocation(),
					excelSheetReportData.getSheetParameters(),
					reportDataSource);
		} else {
			jasperPrint = JasperFillManager.fillReport(
					excelSheetReportData.getSheetReport(),
					excelSheetReportData.getSheetParameters(),
					reportDataSource);
		}
		jasperPrints.add(jasperPrint);
	}

	JasperPrint firstJasperPrint = jasperPrints.get(0);
	if (jasperPrints.size() > 1) {
		for (i = 1; i < jasperPrints.size(); i++) {
			List<JRPrintPage> additionalPages = new ArrayList<JRPrintPage>(
					jasperPrints.get(i).getPages());
			int fistJasperPrintPages = firstJasperPrint.getPages().size();
			for (int count = 0; count < additionalPages.size(); count++) {
				firstJasperPrint.addPage(fistJasperPrintPages,
						additionalPages.get(count));
			}
		}
	}

	JRExporter exporter = new JExcelApiExporter();
	exporter.setParameter(JRXlsExporterParameter.JASPER_PRINT,
			firstJasperPrint);
	exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE,
			Boolean.TRUE);
	exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,
			Boolean.FALSE);

	exporter.setParameter(
			JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
			Boolean.TRUE);
	exporter.setParameter(
			JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS,
			Boolean.TRUE);
	exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,
			Boolean.TRUE);
	exporter.setParameter(JRXlsExporterParameter.SHEET_NAMES,
			sheetNamesArray);
	exporter.setParameter(JExcelApiExporterParameter.IS_COLLAPSE_ROW_SPAN,
			Boolean.TRUE);
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream(32768);
	exporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM,
			outputStream);
	// exporter.setParameter(JRXlsExporterParameter.OUTPUT_FILE_NAME,
	// "C:/development/workspaces/jasper/report1.xls");
	exporter.exportReport();
	return outputStream.toByteArray();
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:76,代码来源:ReportServiceImpl.java

示例5: createExporterThread

import net.sf.jasperreports.engine.JRExporter; //导入方法依赖的package包/类
private void createExporterThread(final JRExporter exporter, final PipedOutputStream pos) {
	Thread thread = new Thread(new Runnable() {

		@Override
		public void run() {
			try {
				exporter.exportReport();
				pos.close();
			} catch (JRException | IOException e) {
				Log.error("An error has occured while exporting report", e);
			}
		}
	}, THREAD_NAME);
	thread.start();
}
 
开发者ID:frincon,项目名称:openeos,代码行数:16,代码来源:JasperReportsEngine.java

示例6: exportFile

import net.sf.jasperreports.engine.JRExporter; //导入方法依赖的package包/类
/**
 * Exports the report to a file in PDF format.
 *
 * @param filename file path of the exported report
 * @throws JRException if an error during exporting occurs
 */
public void exportFile(String filename) throws JRException {
    JRExporter exporter = new JRPdfExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, filledReportPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, filename);
    exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");

    exporter.exportReport();
}
 
开发者ID:oskopek,项目名称:carcv,代码行数:16,代码来源:BasicReportGenerator.java

示例7: exportStream

import net.sf.jasperreports.engine.JRExporter; //导入方法依赖的package包/类
/**
 * Writes the report into the OutputStream in PDF format.
 *
 * @param filename filename of the exported report
 * @param out the output stream to print the report to
 * @throws JRException if an error during exporting occurs
 */
public void exportStream(String filename, OutputStream out) throws JRException {
    JRExporter exporter = new JRPdfExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, filledReportPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, filename);
    exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);

    exporter.exportReport();
}
 
开发者ID:oskopek,项目名称:carcv,代码行数:18,代码来源:BasicReportGenerator.java

示例8: render

import net.sf.jasperreports.engine.JRExporter; //导入方法依赖的package包/类
/**
 * Render the supplied {@code JasperPrint} instance using the
 * supplied {@code JRAbstractExporter} instance and write the results
 * to the supplied {@code Writer}.
 * <p>Make sure that the {@code JRAbstractExporter} implementation
 * you supply is capable of writing to a {@code Writer}.
 * @param exporter the {@code JRAbstractExporter} to use to render the report
 * @param print the {@code JasperPrint} instance to render
 * @param writer the {@code Writer} to write the result to
 * @throws JRException if rendering failed
 */
public static void render(JRExporter exporter, JasperPrint print, Writer writer)
		throws JRException {

	exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
	exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, writer);
	exporter.exportReport();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:JasperReportsUtils.java


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