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


Java SimpleHtmlExporterOutput类代码示例

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


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

示例1: saveHTMLReportToFile

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

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

示例8: getExporter

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

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

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

示例9: getExporter

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

import net.sf.jasperreports.export.SimpleHtmlExporterOutput; //导入依赖的package包/类
private SimpleHtmlExporterOutput simpleHtmlExporterOutput(JasperIExporter jasperExporter) {
	if (jasperExporter.getOutputWriter() != null) {
		return new SimpleHtmlExporterOutput(jasperExporter.getOutputWriter());
	}
	if (jasperExporter.getOutputStream() != null) {
		if (jasperExporter.getCharacterEncoding() != null) {
			return new SimpleHtmlExporterOutput(jasperExporter.getOutputStream(), jasperExporter.getCharacterEncoding());
		}
		else {
			return new SimpleHtmlExporterOutput(jasperExporter.getOutputStream());
		}
	}
	if (jasperExporter.getOutputFile() != null) {
		if (jasperExporter.getCharacterEncoding() != null) {
			return new SimpleHtmlExporterOutput(jasperExporter.getOutputFile(), jasperExporter.getCharacterEncoding());
		}
		else {
			return new SimpleHtmlExporterOutput(jasperExporter.getOutputFile());
		}
	}
	if (jasperExporter.getOutputFileName() != null) {
		if (jasperExporter.getCharacterEncoding() != null) {
			return new SimpleHtmlExporterOutput(jasperExporter.getOutputFileName(), jasperExporter.getCharacterEncoding());
		}
		else {
			return new SimpleHtmlExporterOutput(jasperExporter.getOutputFileName());
		}
	}
	return null;
}
 
开发者ID:svn2github,项目名称:dynamicreports-jasper,代码行数:31,代码来源:ExporterTransform.java

示例11: setHtmlConfigurationFromExportParameters

import net.sf.jasperreports.export.SimpleHtmlExporterOutput; //导入依赖的package包/类
/**
 * Configures a SimpleHtmlReportConfiguration and a SimpleHtmlExporterOutput from a parameter map.
 * 
 * This method allows backwards compatibility when generating HTML reports by using a parameter
 * map to define the export configuration. The usage of this parameter map is deprecated in the
 * Jasper Reports library to use the SimpleHtmlReportConfiguration and SimpleHtmlExporterOutput
 * classes instead.
 * 
 * @param params
 *          A parameter map with the export parameters.
 * @param configuration
 *          The SimpleHtmlReportConfiguration object generated based on the parameter map.
 * @param exporterOutput
 *          The SimpleHtmlExporterOutput object generated based on the parameter map.
 * 
 */
@SuppressWarnings("deprecation")
private static void setHtmlConfigurationFromExportParameters(Map<Object, Object> params,
    SimpleHtmlReportConfiguration configuration, SimpleHtmlExporterOutput exporterOutput) {
  // Add configuration defaults
  // This is needed just in case the params map only contains the Images URI parameter
  configuration.setSizeUnit(HtmlSizeUnitEnum.POINT);
  for (Entry<Object, Object> pair : params.entrySet()) {
    Object key = pair.getKey();
    String parameter;
    if (key instanceof net.sf.jasperreports.engine.JRExporterParameter) {
      parameter = ((net.sf.jasperreports.engine.JRExporterParameter) key).toString();
    } else if (key instanceof String) {
      parameter = (String) key;
    } else {
      parameter = "";
    }
    if (parameter.equals(IMAGES_URI)) {
      exporterOutput.setImageHandler(new WebHtmlResourceHandler((String) pair.getValue()));
    } else if (parameter.equals("Is Remove Empty Space Between Rows")) {
      configuration.setRemoveEmptySpaceBetweenRows((Boolean) pair.getValue());
    } else if (parameter.equals("Size Unit")) {
      String sizeUnit = (String) pair.getValue();
      if (HtmlSizeUnitEnum.POINT.getName().equals(sizeUnit)) {
        configuration.setSizeUnit(HtmlSizeUnitEnum.POINT);
      } else if (HtmlSizeUnitEnum.PIXEL.getName().equals(sizeUnit)) {
        configuration.setSizeUnit(HtmlSizeUnitEnum.PIXEL);
      }
    } else if (parameter.equals("Ignore page margins")) {
      configuration.setIgnorePageMargins((Boolean) pair.getValue());
    } else if (parameter.equals("Is White Page Background")) {
      configuration.setWhitePageBackground((Boolean) pair.getValue());
    } else if (parameter.equals("Is Wrap Break Word")) {
      configuration.setWrapBreakWord((Boolean) pair.getValue());
    } else if (parameter.equals("Zoom Ratio")) {
      configuration.setZoomRatio((Float) pair.getValue());
    } else {
      log.warn("Unknown HTML export configuration parameter: " + parameter);
    }
  }
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:57,代码来源:ReportingUtils.java

示例12: service

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

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

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

	File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".rtf");
	
	JRRtfExporter exporter = new JRRtfExporter();
	
	exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
	exporter.setExporterOutput(new SimpleHtmlExporterOutput(destFile));
	
	exporter.exportReport();

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

示例15: saveHTMLReport

import net.sf.jasperreports.export.SimpleHtmlExporterOutput; //导入依赖的package包/类
/**
 * Generates an HTML report using the SimpleExporterInput, SimpleHtmlExporterOutput and
 * SimpleHtmlReportConfiguration received as parameters.
 * 
 * @param exporterInput
 *          SimpleExporterInput object with the input data.
 * @param exporterOutput
 *          SimpleHtmlExporterOutput object with the output data.
 * @param exportConfiguration
 *          SimpleHtmlReportConfiguration with the configuration data.
 * @throws JRException
 *           In case there is any error generating the report an exception is thrown with the
 *           error message.
 */
public static void saveHTMLReport(SimpleExporterInput exporterInput,
    SimpleHtmlExporterOutput exporterOutput, SimpleHtmlReportConfiguration exportConfiguration)
    throws JRException {
  final HtmlExporter htmlExporter = new HtmlExporter();
  htmlExporter.setExporterInput(exporterInput);
  htmlExporter.setExporterOutput(exporterOutput);
  htmlExporter.setConfiguration(exportConfiguration);
  htmlExporter.exportReport();
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:24,代码来源:ReportingUtils.java


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