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


Java HtmlExporter类代码示例

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


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

示例1: saveHTMLReportToFile

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

示例2: html

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
/**
 *
 */
public void html() throws JRException
{
	long start = System.currentTimeMillis();
	List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>();
	jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report1.jrprint"));
	jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report2.jrprint"));
	jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report3.jrprint"));
	
	HtmlExporter exporter = new HtmlExporter();
	
	exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
	exporter.setExporterOutput(new SimpleHtmlExporterOutput("build/reports/BatchExportReport.html"));
	
	exporter.exportReport();
	
	System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:21,代码来源:BatchExportApp.java

示例3: saveHTMLReportToOutputStream

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
/**
 * Generates an HTML report from a pre-compiled report and returns it into an output stream.
 * 
 * @param jasperPrint
 *          JasperPrint object which contains a compiled report.
 * @param exportParameters
 *          Export parameters than can be added to configure the resulting report.
 * @param outputStream
 *          The output stream 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 saveHTMLReportToOutputStream(JasperPrint jasperPrint,
    Map<Object, Object> exportParameters, OutputStream outputStream) throws JRException {
  final HtmlExporter htmlExporter = new HtmlExporter();
  SimpleExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
  SimpleHtmlExporterOutput exporterOutput = new SimpleHtmlExporterOutput(outputStream);

  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);
  try {
    htmlExporter.exportReport();
  } catch (Exception e) {
    // Handle the exception to ignore the error thrown when the user closes the browser before
    // getting the whole HTML report
    Throwable t = e.getCause();
    if (t != null && !(t.toString().contains("ClientAbortException"))) {
      throw new JRException(e.getMessage(), e);
    }
  }
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:43,代码来源:ReportingUtils.java

示例4: html

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

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

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".html");
	
	HtmlExporter exporter = new HtmlExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleHtmlExporterOutput(destFile));
	
	SimpleHtmlExporterConfiguration exporterConfig = new SimpleHtmlExporterConfiguration();
	exporterConfig.setBetweenPagesHtml("");
	exporter.setConfiguration(exporterConfig);

	SimpleHtmlReportConfiguration reportConfig = new SimpleHtmlReportConfiguration();
	reportConfig.setRemoveEmptySpaceBetweenRows(true);
	exporter.setConfiguration(reportConfig);
	
	exporter.exportReport();

	System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:30,代码来源:NoPageBreakApp.java

示例5: save

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
@Override
public void save(JasperPrint jasperPrint, File file) throws JRException
{
	if (
		!file.getName().toLowerCase().endsWith(EXTENSION_HTM)
		&& !file.getName().toLowerCase().endsWith(EXTENSION_HTML)
		)
	{
		file = new File(file.getAbsolutePath() + EXTENSION_HTML);
	}
		
	if (
		!file.exists() ||
		JOptionPane.OK_OPTION == 
			JOptionPane.showConfirmDialog(
				null, 
				MessageFormat.format(
					getBundleString("file.exists"),
					new Object[]{file.getName()}
					), 
				getBundleString("save"), 
				JOptionPane.OK_CANCEL_OPTION
				)
		)
	{
		HtmlExporter exporter = new HtmlExporter(getJasperReportsContext());
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); 
		exporter.setExporterOutput(new SimpleHtmlExporterOutput(file));
		exporter.exportReport(); 
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:32,代码来源:JRHtmlSaveContributor.java

示例6: exportToHtmlFile

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
/**
 * Exports the generated report object received as parameter into HTML format,
 * placing the result into the second file parameter.
 * <p>
 * The images are placed as distinct files inside a directory having the same name 
 * as the HTML destination file, plus the "_files" suffix. 
 * 
 * @param jasperPrint  report object to export
 * @param destFileName file name to place the HTML content into
 * @see net.sf.jasperreports.engine.export.JRPdfExporter
 */
public void exportToHtmlFile(
	JasperPrint jasperPrint, 
	String destFileName
	) throws JRException
{
	HtmlExporter exporter = new HtmlExporter(jasperReportsContext);
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleHtmlExporterOutput(destFileName));
	
	exporter.exportReport();
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:24,代码来源:JasperExportManager.java

示例7: createColumnGroupCell

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
@Override
protected JRElement createColumnGroupCell(ColumnGroup columnGroup, Cell cell, JRDesignElementGroup elementGroup)
{
	JRDesignFrame frame = (JRDesignFrame) createCell(elementGroup, cell, 
			columnGroup.getWidth(), fillColumn.getWidth(), 
			xOffset, yOffset, null, deriveUUID(), true);
	frame.getPropertiesMap().setProperty(HtmlExporter.PROPERTY_HTML_CLASS, "jrcolGroupHeader");
	return frame;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:10,代码来源:TableReport.java

示例8: exportXhtml

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
public void exportXhtml() throws JRException {
	HtmlExporter exporter = new HtmlExporter();
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleHtmlExporterOutput(this.output
			.getAbsolutePath() + ".x.html"));
	exporter.exportReport();
}
 
开发者ID:vosskaem,项目名称:jasperstarter,代码行数:8,代码来源:Report.java

示例9: getExporter

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
@Override
protected HtmlExporter getExporter(JasperReportsConfiguration jContext, JRExportProgressMonitor monitor, File file) {
	HtmlExporter exp = new HtmlExporter(jContext);
	exp.setExporterOutput(new SimpleHtmlExporterOutput(file));

	SimpleHtmlReportConfiguration rconf = new SimpleHtmlReportConfiguration();
	setupReportConfiguration(rconf, monitor);
	exp.setConfiguration(rconf);
	return exp;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:11,代码来源:ExportAsLHtmlAction.java

示例10: export

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
/**
 * Exports by MIME type.
 *
 * @param mimeType MIME type
 * @param jp       Jasper print
 * @param os       outputstream
 * @throws JRException
 */
protected void export(String mimeType, JasperPrint jp, OutputStream os) throws JRException {
    if ("application/pdf".equalsIgnoreCase(mimeType)) {
        exportReport(new JRPdfExporter(), jp, os);

    } else if ("text/xml".equalsIgnoreCase(mimeType)) {
        exportReport(new HtmlExporter(), jp, os);

    } else if ("application/rtf".equalsIgnoreCase(mimeType)) {
        exportReport(new JRRtfExporter(), jp, os);

    } else if ("application/xls".equalsIgnoreCase(mimeType)) {
        exportReport(new JRXlsExporter(), jp, os);

    } else if ("application/odt".equalsIgnoreCase(mimeType)) {
        exportReport(new JROdtExporter(), jp, os);

    } else if ("application/ods".equalsIgnoreCase(mimeType)) {
        exportReport(new JROdsExporter(), jp, os);

    } else if ("application/docx".equalsIgnoreCase(mimeType)) {
        exportReport(new JRDocxExporter(), jp, os);

    } else if ("application/xlsx".equalsIgnoreCase(mimeType)) {
        exportReport(new JRXlsxExporter(), jp, os);

    } else if ("application/pptx".equalsIgnoreCase(mimeType)) {
        exportReport(new JRPptxExporter(), jp, os);

    } else if ("text/xhmtl".equalsIgnoreCase(mimeType)) {
        exportReport(new JRXhtmlExporter(), jp, os);
    } else {
        throw new IllegalArgumentException("JasperRenderer does not support " + mimeType + " MIME type.");
    }
}
 
开发者ID:seedstack,项目名称:io-addon,代码行数:43,代码来源:JasperRenderer.java

示例11: getHandler

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
@Override
public GenericElementHandler getHandler(String elementName, String exporterKey) {
	if (handlers.containsKey(elementName)) {
		if (HtmlExporter.HTML_EXPORTER_KEY.equals(exporterKey)) {
			return handlers.get(elementName);
		}
	}
	return null;
}
 
开发者ID:svn2github,项目名称:dynamicreports-jasper,代码行数:10,代码来源:GoogleChartsHandler.java

示例12: service

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
@Override
public void service(
	HttpServletRequest request,
	HttpServletResponse response
	) throws IOException, ServletException
{
	ServletContext context = this.getServletConfig().getServletContext();

	response.setContentType("text/html");
	PrintWriter out = response.getWriter();

	try
	{
		File reportFile = new File(context.getRealPath("/reports/WebappReport.jasper"));
		if (!reportFile.exists())
			throw new JRRuntimeException("File WebappReport.jasper not found. The report design must be compiled first.");

		JasperReport jasperReport = (JasperReport)JRLoader.loadObjectFromFile(reportFile.getPath());
	
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("ReportTitle", "Address Report");
		parameters.put("BaseDir", reportFile.getParentFile());
					
		JasperPrint jasperPrint = 
			JasperFillManager.fillReport(
				jasperReport, 
				parameters, 
				new WebappDataSource()
				);
					
		HtmlExporter exporter = new HtmlExporter();
	
		request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
		
		exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
		SimpleHtmlExporterOutput output = new SimpleHtmlExporterOutput(out);
		output.setImageHandler(new WebHtmlResourceHandler("image?image={0}"));
		exporter.setExporterOutput(output);
		
		exporter.exportReport();
	}
	catch (JRException e)
	{
		out.println("<html>");
		out.println("<head>");
		out.println("<title>JasperReports - Web Application Sample</title>");
		out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"../stylesheet.css\" title=\"Style\">");
		out.println("</head>");
		
		out.println("<body bgcolor=\"white\">");

		out.println("<span class=\"bnew\">JasperReports encountered this error :</span>");
		out.println("<pre>");

		e.printStackTrace(out);

		out.println("</pre>");

		out.println("</body>");
		out.println("</html>");
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:63,代码来源:HtmlServlet.java

示例13: html

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

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

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".html");

	HtmlExporter exporter = new HtmlExporter();

	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleHtmlExporterOutput(destFile));

	exporter.exportReport();

	System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:22,代码来源:StylesApp.java

示例14: getHandler

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
@Override
public GenericElementHandler getHandler(String elementName,
		String exporterKey)
{
	if (NAME.equals(elementName)
			&& JRPdfExporter.PDF_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementPdfHandler();
	}
	else if (NAME.equals(elementName)
			&& HtmlExporter.HTML_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementHtmlHandler();
	}
	else if (NAME.equals(elementName)
			&& JRXlsExporter.XLS_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementXlsHandler();
	}
	else if (NAME.equals(elementName)
			&& JRGraphics2DExporter.GRAPHICS2D_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementGraphics2DHandler();
	}		
	else if (NAME.equals(elementName)
			&& JRDocxExporter.DOCX_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementDocxHandler();
	}		
	else if (NAME.equals(elementName)
			&& JRPptxExporter.PPTX_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementPptxHandler();
	}
	else if (NAME.equals(elementName)
			&& JRXlsxExporter.XLSX_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementXlsxHandler();
	}
	else if (NAME.equals(elementName)
			&& JRRtfExporter.RTF_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementRtfHandler();
	}
	else if (NAME.equals(elementName)
			&& JROdtExporter.ODT_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementOdtHandler();
	}
	else if (NAME.equals(elementName)
			&& JROdsExporter.ODS_EXPORTER_KEY.equals(exporterKey))
	{
		return new HtmlElementOdsHandler();
	}		
	return null;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:57,代码来源:HtmlElementHandlerBundle.java

示例15: addHtmlClass

import net.sf.jasperreports.engine.export.HtmlExporter; //导入依赖的package包/类
protected void addHtmlClass(String className)
{
	String originalClasses = printProperties.get(HtmlExporter.PROPERTY_HTML_CLASS);
	String newClasses = originalClasses == null ? className : (originalClasses + " " + className);
	setPrintProperty(HtmlExporter.PROPERTY_HTML_CLASS, newClasses);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:7,代码来源:JRFillCellContents.java


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