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


Java JExcelApiExporter类代码示例

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


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

示例1: jxl

import net.sf.jasperreports.engine.export.JExcelApiExporter; //导入依赖的package包/类
/**
 *
 */
public void jxl() 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() + ".jxl.xls");
	
	JExcelApiExporter exporter = new JExcelApiExporter();
	
	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

示例2: exportElement

import net.sf.jasperreports.engine.export.JExcelApiExporter; //导入依赖的package包/类
@Override
public void exportElement(JExcelApiExporterContext exporterContext,
    JRGenericPrintElement element, JRExporterGridCell gridCell,
    int colIndex, int rowIndex, int emptyCols, int yCutsRow,
    JRGridLayout layout) {
  try {
    JExcelApiExporter exporter = (JExcelApiExporter) exporterContext
        .getExporter();
    JasperReportsContext reportsContext = exporterContext
        .getJasperReportsContext();
    JRPrintImage printImage = getImage(reportsContext, element);
    exporter.exportImage(printImage, gridCell, colIndex, rowIndex, emptyCols,
        yCutsRow, layout);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:sourcepole,项目名称:jasperreports-wms-component,代码行数:18,代码来源:WmsMapElementJExcelApiHandler.java

示例3: createExporter

import net.sf.jasperreports.engine.export.JExcelApiExporter; //导入依赖的package包/类
@Override
protected JExcelApiExporter createExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor) {
	JExcelApiExporter exp = new JExcelApiExporter(jContext);

	SimpleJxlReportConfiguration rconf = new SimpleJxlReportConfiguration();
	setupReportConfiguration(rconf, monitor);
	exp.setConfiguration(rconf);

	return exp;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:11,代码来源:ExportAsExcelAPIAction.java

示例4: generateExcel

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

import net.sf.jasperreports.engine.export.JExcelApiExporter; //导入依赖的package包/类
/**
 * generate a ByteArrayOutputStream from given JasperPrint object for the Excel report
 *
 * @param jasperPrint transform to excel report
 * @return reporting ByteArrayOutputStream
 * @throws ReportingException when the JasperPrint null
 * @throws JRException
 */
public ByteArrayOutputStream generateExcelReport(JasperPrint jasperPrint) throws ReportingException, JRException {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    if (jasperPrint == null) {
        throw new ReportingException("jasperPrint null, can't convert to excel report");
    }
    try {
        // Remove the pageHeader from pages except starting page
        jasperPrint.setProperty("net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1", "pageHeader");
  // Remove the column headers except the first one
        jasperPrint.setProperty("net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.2", "columnHeader");

        //  Remove the pageFooter from all the pages
        jasperPrint.setProperty("net.sf.jasperreports.export.xls.exclude.origin.band.2", "pageFooter");
        //  set the JXL parameters to generate Excel report
        JExcelApiExporter jExcelApiExporter = new JExcelApiExporter();
        jExcelApiExporter.setParameter(JExcelApiExporterParameter.JASPER_PRINT, jasperPrint);
        jExcelApiExporter.setParameter(JExcelApiExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
        jExcelApiExporter.setParameter(JExcelApiExporterParameter.OUTPUT_STREAM, outputStream);
        jExcelApiExporter.setParameter(JExcelApiExporterParameter.IS_IGNORE_CELL_BORDER,Boolean.TRUE);
        jExcelApiExporter.setParameter(JExcelApiExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE);
        jExcelApiExporter.setParameter(JExcelApiExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
        jExcelApiExporter.setParameter(JExcelApiExporterParameter.OFFSET_X,0);
        jExcelApiExporter.setParameter(JExcelApiExporterParameter.OFFSET_Y,0 );
        jExcelApiExporter.exportReport();

    } catch (JRException e) {
        throw new JRException("Error occurred exporting Excel report ", e);
    }
    return outputStream;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:40,代码来源:ExcelReport.java

示例6: getHandler

import net.sf.jasperreports.engine.export.JExcelApiExporter; //导入依赖的package包/类
@Override
public GenericElementHandler getHandler(String elementName,
    String exporterKey) {
  if (WmsMapPrintElement.WMS_MAP_ELEMENT_NAME.equals(elementName)) {
    if (JRGraphics2DExporter.GRAPHICS2D_EXPORTER_KEY
        .equals(exporterKey)) {
      return WmsMapElementGraphics2DHandler.getInstance();
    }
    if (JRHtmlExporter.HTML_EXPORTER_KEY.equals(exporterKey)
        || JRXhtmlExporter.XHTML_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementHtmlHandler.getInstance();
    }
    else if (JRPdfExporter.PDF_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementPdfHandler.getInstance();
    }
    else if (JRXlsExporter.XLS_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementXlsHandler.getInstance();
    }
    else if (JExcelApiExporter.JXL_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementJExcelApiHandler.getInstance();
    }
    // else
    // if(JExcelApiMetadataExporter.JXL_METADATA_EXPORTER_KEY.equals(exporterKey))
    // {
    // return MapElementJExcelApiMetadataHandler.getInstance();
    // }
    else if (JRXlsxExporter.XLSX_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementXlsxHandler.getInstance();
    }
    else if (JRDocxExporter.DOCX_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementDocxHandler.getInstance();
    }
    else if (JRPptxExporter.PPTX_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementPptxHandler.getInstance();
    }
    else if (JRRtfExporter.RTF_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementRtfHandler.getInstance();
    }
    else if (JROdtExporter.ODT_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementOdtHandler.getInstance();
    }
    else if (JROdsExporter.ODS_EXPORTER_KEY.equals(exporterKey)) {
      return WmsMapElementOdsHandler.getInstance();
    }
  }
  return null;
}
 
开发者ID:sourcepole,项目名称:jasperreports-wms-component,代码行数:48,代码来源:ExtensionsRegistryFactory.java


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