碧玉生成的报告的列缩小

时间:2019-12-16 13:45:36

标签: java jasper-reports

伙计们,我正在使用JRHtmlExporter从设计的jrxml生成html报告,代码如下

    final StringBuffer sbuffer = new StringBuffer();
    JRHtmlExporter exporter = new JRHtmlExporter();
    JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(result); 
    JasperDesign design = JRXmlLoader.load("jrxml path"));
    JasperReport jasperPrint = JasperCompileManager.compileReport(design);

    JasperFillManager.fillReport(jasperReport, parameters, beanColDataSource);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, sbuffer);
    exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"./servlets/image?image=");
    exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(0));
    exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");
    exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");
    exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");
    exporter.exportReport(); 

,报告生成如下 enter image description here

这是我想要的正确格式。现在,我已经开始使用HtmlExporter从jrxml生成html报告,代码如下

public StringBuffer export() throws FileNotFoundException, JRException {
    final StringBuffer sb = new StringBuffer();
    JasperDesign design = JRXmlLoader.load("jrxml path"));
    JasperReport jasperReport = JasperCompileManager.compileReport(design);
    JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(collections);

    JasperReportsContext context = DefaultJasperReportsContext.getInstance();
    context.setProperty("net.sf.jasperreports.export.html.white.page.background", "false");
    JasperPrint jasperPrint = JasperFillManager.getInstance(context)
                .fill(jasperReport, parrametersMap, beanColDataSource);
    HtmlExporter exporter = new HtmlExporter();
    exporter.setExporterInput(SimpleExporterInput.getInstance(Arrays.asList(jasperPrint)));
    SimpleHtmlExporterOutput expOutput = new SimpleHtmlExporterOutput(sb);
    expOutput.setImageHandler(new WebHtmlResourceHandler("./servlets/image?image="));
    exporter.setExporterOutput(expOutput);

    Configuration configuration = new Configuration.Builder()
                .betweenPagesHtml("")
                .htmlFooter("")
                .htmlHeader("")
                .overrideHints(false)
                .flushOutput(false)
                .build();
        exporter.setConfiguration(configuration); 
        exporter.exportReport();
    return sb;
}

报告看起来像
enter image description here

问题是,当列的数据增加时,它会缩小另一列而不是扩展该列。对于JRHtmlExporter,它将调整表和列的大小。我期望HtmlExporter具有相同的功能,但无法正常工作。

我不想使用CSS

  table{
           width:100%;
      } 

在渲染时,因为一个小报告占了我不想要的100%。

我的代码中缺少什么?

0 个答案:

没有答案