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


Java JRHtmlExporterParameter类代码示例

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


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

示例1: export

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
	res.setContentType("text/html;charset=UTF-8");
	JRHtmlExporter exporter=new JRHtmlExporter(DefaultJasperReportsContext.getInstance());
	JasperPrint jasperPrint=this.getJasperPrint(req);
	req.getSession().setAttribute(BaseHttpServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);
	exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
	OutputStream ouputStream = res.getOutputStream();
	exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
	String path=req.getContextPath();
	if(path.endsWith("/")){
		path+="dorado/bdf2/jasperreports/html.image";
	}else{
		path+="/dorado/bdf2/jasperreports/html.image";			
	}
	exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,path+"?image=");
	try {
		exporter.exportReport();
	} catch (JRException e) {
		throw new ServletException(e);
	} finally {
		if (ouputStream != null) {
			ouputStream.flush();
			ouputStream.close();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:27,代码来源:HtmlExporter.java

示例2: load

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
public void load() {
    setInit(true);
    Preferences pref = IReportManager.getPreferences();
    JRPropertiesUtil jrPropUtils = IRLocalJasperReportsContext.getUtilities();
    JasperReportsContext context = IRLocalJasperReportsContext.getInstance();
    
    jCheckBoxFrameAsNestedTables.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES)));
    jCheckBoxRemoveEmptySpace.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS)));
    jCheckBoxSaveImages.setSelected( pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.saveImages", true));
    jCheckBoxUseImagesToAlign.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN)));
    jCheckBoxWhiteBackground.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND)));
    jCheckBoxWrapBreakWord.setSelected( pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD)));

    jTextFieldImagesDirectory.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory",""));
    jTextFieldImagesDirectory1.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri",""));

    jTextAreaHtmlBetweenPages.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages",""));
    jTextAreaHtmlFooter.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter",""));
    jTextAreaHtmlHeader.setText(  pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader",""));
    jComboBox1.setSelectedItem(  pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)));
    setInit(false);
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:23,代码来源:HtmlExportParametersPanel.java

示例3: store

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
public void store() {

        Preferences pref = IReportManager.getPreferences();

        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES,  jCheckBoxFrameAsNestedTables.isSelected() );
        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,  jCheckBoxRemoveEmptySpace.isSelected() );
        pref.putBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.saveImages",  jCheckBoxSaveImages.isSelected() );
        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN,  jCheckBoxUseImagesToAlign.isSelected() );
        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND,  jCheckBoxWhiteBackground.isSelected() );
        pref.putBoolean(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD,  jCheckBoxWrapBreakWord.isSelected() );

        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory", jTextFieldImagesDirectory.getText());
        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri", jTextFieldImagesDirectory1.getText());
        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages", jTextAreaHtmlBetweenPages.getText());
        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter", jTextAreaHtmlFooter.getText());
        pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader", jTextAreaHtmlHeader.getText());
        pref.put(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jComboBox1.getSelectedItem()+"");

      }
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:20,代码来源:HtmlExportParametersPanel.java

示例4: exportToHTML

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
private void exportToHTML() {
    log.debug("exporting to HTML");
    htmlExporter = new JRHtmlExporter();
    setExportParameter(JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
    setExportParameter(JRHtmlExporterParameter.IMAGES_URI,"servlets/image?image=");
    setExportParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.TRUE);
    setExportParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
    setExportParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
    htmlExporter.setParameters(getExportParameters());
    try {
        start = System.currentTimeMillis();
        htmlExporter.exportReport();
        log.info("export running time (msec): "
                + (System.currentTimeMillis() - start));
    } catch (JRException jre) {
        jre.printStackTrace();
    }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:19,代码来源:OOReportGenerator.java

示例5: getHTML

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
public static byte[] getHTML(StorageService storageService, JasperPrint jasperPrint)
        throws JRException {
    byte[] content = null;
    ByteArrayOutputStream baos = null;
    try {
        baos = new ByteArrayOutputStream();
        JRHtmlExporter exporter = new JRHtmlExporter();
        // Jasper Images will be stored to reports home directory
        // so to be accesed from HTML
        exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME, storageService.getSettings().getReportsHome());
        exporter.setParameter(JRHtmlExporterParameter.SIZE_UNIT, "px");
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "./");
        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,代码行数:27,代码来源:JasperReportsUtil.java

示例6: renderAsHtmlWithExporterParameters

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
@Test
public void renderAsHtmlWithExporterParameters() throws Exception {
	StringWriter writer = new StringWriter();
	Map<JRExporterParameter, Object> exporterParameters = new HashMap<JRExporterParameter, Object>();
	String uri = "/my/uri";
	exporterParameters.put(JRHtmlExporterParameter.IMAGES_URI, uri);
	JasperReportsUtils.renderAsHtml(getReport(), getParameters(), getData(), writer, exporterParameters);
	String output = writer.getBuffer().toString();
	assertHtmlOutputCorrect(output);
	assertTrue("URI not included", output.contains(uri));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:JasperReportsUtilsTests.java

示例7: configureXHtmlExporter

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
private void configureXHtmlExporter(JRExporter exporter, SimpleJasperReportsContext context) {

        Preferences pref = IReportManager.getPreferences();
        JRPropertiesUtil jrPropUtils = JRPropertiesUtil.getInstance(context);

        exporter.setParameter( JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.saveImages", true));
        exporter.setParameter( JRHtmlExporterParameter.IS_WHITE_PAGE_BACKGROUND, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND)));
        exporter.setParameter( JRHtmlExporterParameter.IS_WRAP_BREAK_WORD, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD)));

        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter",""));
        }
        if (pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)).length() > 0)
        {
            context.setValue( JRHtmlExporterParameter.PROPERTY_SIZE_UNIT , pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)));
        }

    }
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:36,代码来源:DefaultExporterFactory.java

示例8: configureHtmlExporter

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
private void configureHtmlExporter(JRExporter exporter, SimpleJasperReportsContext context) {

        Preferences pref = IReportManager.getPreferences();
        JRPropertiesUtil jrPropUtils = JRPropertiesUtil.getInstance(context);

        context.setValue( JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_FRAMES_AS_NESTED_TABLES)));
        context.setValue( JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS)));
        exporter.setParameter( JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.saveImages", true));
        context.setValue( JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_USING_IMAGES_TO_ALIGN)));
        context.setValue( JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND)));
        context.setValue( JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD, pref.getBoolean(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD, jrPropUtils.getBooleanProperty(JRHtmlExporterParameter.PROPERTY_WRAP_BREAK_WORD)));

        //FIXME these properties do not actually exist!!!!!!!..... check all properties

        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesDirectory",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.imagesUri",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader","").length() > 0)
        {
            context.setValue(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlHeader",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages" , pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlBetweenPages",""));
        }
        if (pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter","").length() > 0)
        {
            context.setValue( JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter", pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.html.htmlFooter",""));
        }
        if (pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)).length() > 0)
        {
            context.setValue( JRHtmlExporterParameter.PROPERTY_SIZE_UNIT , pref.get(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT, jrPropUtils.getProperty(JRHtmlExporterParameter.PROPERTY_SIZE_UNIT)));
        }

    }
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:41,代码来源:DefaultExporterFactory.java

示例9: testTypeConversion

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
public void testTypeConversion() {
	Map params = new HashMap();
	params.put("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN", "true");

	AbstractJasperReportsView view = new JasperReportsHtmlView();
	setViewProperties(view);

	view.setExporterParameters(params);
	view.convertExporterParameters();
	Object value = view.getConvertedExporterParameters().get(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN);
	assertEquals(Boolean.TRUE, value);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:13,代码来源:ExporterParameterTests.java

示例10: testConfigureExporterParametersWithEncodingFromPropertiesFile

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
public void testConfigureExporterParametersWithEncodingFromPropertiesFile() throws Exception {
	GenericWebApplicationContext ac = new GenericWebApplicationContext();
	ac.setServletContext(new MockServletContext());
	BeanDefinitionReader reader = new PropertiesBeanDefinitionReader(ac);
	reader.loadBeanDefinitions(new ClassPathResource("view.properties", getClass()));
	ac.refresh();

	AbstractJasperReportsView view = (AbstractJasperReportsView) ac.getBean("report");
	String encoding = (String) view.getConvertedExporterParameters().get(JRHtmlExporterParameter.CHARACTER_ENCODING);
	assertEquals("UTF-8", encoding);

	request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac);
	view.render(getModel(), request, response);
	assertEquals("Response content type is incorrect", "text/html;charset=UTF-8", response.getContentType());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:JasperReportsHtmlViewTests.java

示例11: testRenderAsHtmlWithExporterParameters

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
public void testRenderAsHtmlWithExporterParameters() throws Exception {
	StringWriter writer = new StringWriter();
	Map<JRExporterParameter, Object> exporterParameters = new HashMap<JRExporterParameter, Object>();
	String uri = "/my/uri";
	exporterParameters.put(JRHtmlExporterParameter.IMAGES_URI, uri);
	JasperReportsUtils.renderAsHtml(getReport(), getParameters(), getData(), writer, exporterParameters);
	String output = writer.getBuffer().toString();
	assertHtmlOutputCorrect(output);
	assertTrue("URI not included", output.contains(uri));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:JasperReportsUtilsTests.java

示例12: getHtmlExporter

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
protected JRHtmlExporter getHtmlExporter() {
	JRHtmlExporter exporter = new JRHtmlExporter();
	String random = "" + Math.random() * 1000.0;
	random = random.replace('.', '0').replace(',', '0');
	
	exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, Utils.getWebContextPath(EnterpriseApplication.getInstance()) + "/image?r=" + random + "&image=");
	return exporter;
}
 
开发者ID:alejandro-du,项目名称:enterprise-app,代码行数:9,代码来源:AbstractReport.java

示例13: getHtmlExporter

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
protected JRHtmlExporter getHtmlExporter() {
	JRHtmlExporter exporter = new JRHtmlExporter();
	String random = "" + Math.random() * 1000.0;
	random = random.replace('.', '0').replace(',', '0');
	
	exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, getWebContextPath() + "/image?r=" + random + "&image=");
	return exporter;
}
 
开发者ID:thingtrack,项目名称:konekti,代码行数:9,代码来源:TemplateComponentReport.java

示例14: download

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
/**
  * metodo responsavel pelo preenchimento do relatorio, a partir do arquivo jasper compilado, do nome do arquivo html, 
  * e considerando os dados sob a forma de List e os par�metros 
  * 
  * @param nomeArquivo
  * @param streamRelatorio
  * @param parametros
  * @param dados
  * @throws RelatorioException
  */
 public void download(String nomeArquivo, InputStream streamRelatorio, Map parametros, List dados) throws RelatorioException {

     String caminhoRelatorio = caminhoRelatorioHTML + nomeArquivo;
     System.out.println("CAMINHO RELAT�RIO: " + caminhoRelatorio);

     File relatorio = new File(caminhoRelatorio);
     byte[] buffer = null;

     try {
         FacesContext context = FacesContext.getCurrentInstance();
         HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
         HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getResponse();

         response.setContentType("application/octet-stream");
         response.setHeader("Content-Disposition", "attachment;filename=\"" + nomeArquivo + "\"");

         if (parametros == null) {
             parametros = new HashMap();
         }
         
         //Neste ponto, a nossa lista preenchida com o modelo � entregue ao Jasper, que cria um DataSource com ela
         JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(dados);

         //Aqui � onde ocorre de fato o preenchimento do relat�rio, com os par�metros e DataSource passados
         JasperPrint impressao = JasperFillManager.fillReport(streamRelatorio, parametros, dataSource);

         //Ponto onde o relat�rio com os dados montados � exportado para o formato HTML
         JasperExportManager.exportReportToHtmlFile(impressao, caminhoRelatorio);

         FileInputStream fis = new FileInputStream(relatorio);
         OutputStream os = response.getOutputStream();
         
         response.setContentType("text/html");

         JRHtmlExporter htmlExporter = new JRHtmlExporter();
         
request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, impressao);
htmlExporter.setParameter(JRExporterParameter.JASPER_PRINT, impressao);
htmlExporter.setParameter(JRExporterParameter.OUTPUT_WRITER, os);
htmlExporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/gesplan/image?image=");
htmlExporter.exportReport();

         int read = 0;
         buffer = new byte[1024];

         while ((read = fis.read(buffer)) != -1) {
             os.write(buffer, 0, read);
         }
         
         os.flush();
         os.close();
         fis.close();

         FacesContext.getCurrentInstance().responseComplete();

     } catch (Throwable ex) {
         ex.printStackTrace();
         throw new RelatorioException(ex);
     } finally {
         buffer = null;
     }
 }
 
开发者ID:dayse,项目名称:gesplan,代码行数:73,代码来源:RelatorioHtml.java

示例15: doPost

import net.sf.jasperreports.engine.export.JRHtmlExporterParameter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void doPost(HttpServletRequest request, HttpServletResponse response)
     	throws ServletException, IOException
 	{
	String nomeDoRelatorio = (String)request.getAttribute("nomeDoRelatorio");
	
	System.out.println(">>>>>>>>>>>>>>>Nome do relatorio="+nomeDoRelatorio);
	
	List lista = (List)request.getAttribute("lista");
	
	HashMap<String, String> parametros = (HashMap<String, String>)request.getAttribute("parametros");
	
	ServletContext context = this.getServletContext();
	
	String nomeDoArquivoCompilado = context.getRealPath(nomeDoRelatorio);
	
	System.out.println(">>>>>>>>>>>>>>>>>>>> nomeDoArquivoCompilado="+nomeDoArquivoCompilado);
	File arquivo = new File(nomeDoArquivoCompilado);
	PrintWriter printWriter = response.getWriter();
	
	try
	{	JasperReport relatorioCompilado = (JasperReport) JRLoader.loadObject(arquivo);
           
	    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(lista);

	    JasperPrint impressao = JasperFillManager.fillReport(relatorioCompilado, parametros, ds);

		JRHtmlExporter htmlExporter = new JRHtmlExporter();
		
		response.setContentType("text/html");
		
		request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, impressao);
		htmlExporter.setParameter(JRExporterParameter.JASPER_PRINT, impressao);
		htmlExporter.setParameter(JRExporterParameter.OUTPUT_WRITER, printWriter);
		htmlExporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/gesplan/image?image=");
		htmlExporter.exportReport();
		
	}
	catch(JRException e)
	{	e.printStackTrace(printWriter);
	} 
 	}
 
开发者ID:dayse,项目名称:gesplan,代码行数:43,代码来源:GeraRelatorioEmHTML.java


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