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


Java JRXlsExporter.setParameter方法代码示例

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


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

示例1: export

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

示例2: exportXls

import net.sf.jasperreports.engine.export.JRXlsExporter; //导入方法依赖的package包/类
/**
 * Xls export.
 *
 * @param jp
 * @param os
 */
protected void exportXls(JasperPrint jp, OutputStream os) {
    // Create a JRXlsExporter instance
    JRXlsExporter exporter = new JRXlsExporter();

    // Here we assign the parameters jp and baos to the exporter
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);

    // TODO add Excel specific parameters
    exporter.setParameter(JRXlsAbstractExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
    exporter.setParameter(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
    exporter.setParameter(JRXlsAbstractExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);

    try {
        exporter.exportReport();

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

示例3: xls

import net.sf.jasperreports.engine.export.JRXlsExporter; //导入方法依赖的package包/类
/**
 *
 */
public void xls() throws JRException
{
	long start = System.currentTimeMillis();
	File sourceFile = new File("build/reports/ScriptletReport.jrprint");

	JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");
	
	JRXlsExporter exporter = new JRXlsExporter();
	
	exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
	exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());
	exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
	
	exporter.exportReport();

	System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:23,代码来源:ScriptletApp.java

示例4: exportReportToExcelStream

import net.sf.jasperreports.engine.export.JRXlsExporter; //导入方法依赖的package包/类
private void exportReportToExcelStream(JasperPrint jasperPrint, OutputStream os)
 			throws JRException{
 	JRXlsExporter exp = new JRXlsExporter();
 	exp.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exp.setParameter(JRExporterParameter.OUTPUT_STREAM, os);
exp.setParameter(JRXlsExporterParameter.IGNORE_PAGE_MARGINS, Boolean.TRUE);
exp.setParameter(JRXlsExporterParameter.OFFSET_X, 0);
exp.setParameter(JRXlsExporterParameter.IS_IGNORE_CELL_BORDER, Boolean.FALSE);
exp.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, true);
exp.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, false);
     	exp.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, false);
     	exp.setParameter(JRXlsExporterParameter.MAXIMUM_ROWS_PER_SHEET,Integer.decode("65000"));
 	exp.exportReport();
 }
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:15,代码来源:OscarDocumentCreator.java

示例5: getJREXporter

import net.sf.jasperreports.engine.export.JRXlsExporter; //导入方法依赖的package包/类
private static JRExporter getJREXporter(final String extension) {
		if ("pdf".equalsIgnoreCase(extension)) {
			JRPdfExporter exporter = new JRPdfExporter();
//			exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT, "this.print();");
			
			return exporter;
			
		} else if ("html".equalsIgnoreCase(extension)) {
			return new JRHtmlExporter();
			
		} else if ("xls".equalsIgnoreCase(extension)) {
			 JRXlsExporter exporterXLS = new JRXlsExporter();                
			 exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
			 exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
			 exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
			 exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
			
			return exporterXLS;
			
		} else if ("txt".equalsIgnoreCase(extension)) {
			return new JRTextExporter();
		} else if ("csv".equalsIgnoreCase(extension)) {
			return new JRCsvExporter();
		} else if ("docx".equalsIgnoreCase(extension)) {
			return new JRDocxExporter();
		}
		return null;
	}
 
开发者ID:ldiaz,项目名称:laboratorioSpring,代码行数:29,代码来源:ReportJR.java

示例6: getExcel

import net.sf.jasperreports.engine.export.JRXlsExporter; //导入方法依赖的package包/类
public static byte[] getExcel(JasperPrint jasperPrint, Map<String, Boolean> xlsParameters)
            throws JRException {
        byte[] content = null;
        ByteArrayOutputStream baos = null;
        try {
            baos = new ByteArrayOutputStream();
            JRXlsExporter exporter = new JRXlsExporter();
//            System.out.println("XLS Parameters");
//            System.out.println("--------------");
//            System.out.println("isDetectCellType=" + xlsParameters.get(JasperUtil.IS_DETECT_CELL_TYPE));
//            System.out.println("isWhitePageBackground=" + xlsParameters.get(JasperUtil.IS_WHITE_PAGE_BACKGROUND));
//            System.out.println("isRemoveEmptySpaceBetweenRows=" + xlsParameters.get(JasperUtil.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS));
            exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, xlsParameters.get(JasperUtil.IS_WHITE_PAGE_BACKGROUND));
            exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, xlsParameters.get(JasperUtil.IS_DETECT_CELL_TYPE));
            exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, xlsParameters.get(JasperUtil.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS));
            content = getBytes(exporter, baos, jasperPrint);
        } finally {
            if (baos != null) {
                try {
                    baos.flush();
                    baos.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return content;
    }
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:29,代码来源:JasperReportsUtil.java

示例7: toExcelFile

import net.sf.jasperreports.engine.export.JRXlsExporter; //导入方法依赖的package包/类
public static void toExcelFile(JasperPrint jasperPrint, String xlsFile) throws JRException {
    System.out.println("JasperUtil.toExcelFile");
    Timer timer = new Timer();
    timer.start();

    JRXlsExporter exporter = new JRXlsExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, xlsFile);
    exporter.exportReport();

    timer.end();
    System.out.println("To excel(Xsl) in " + timer.duration());
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:14,代码来源:JasperReportsUtil.java


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