Search in sources :

Example 1 with HTMLExtension

use of org.adempiere.webui.report.HTMLExtension in project adempiere by adempiere.

the class ZkReportViewer method renderReport.

private void renderReport() throws Exception {
    AMedia media = null;
    Listitem selected = previewType.getSelectedItem();
    if (selected == null || "PDF".equals(selected.getValue())) {
        String path = System.getProperty("java.io.tmpdir");
        String prefix = makePrefix(m_reportEngine.getName());
        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
        }
        File file = File.createTempFile(prefix, ".pdf", new File(path));
        m_reportEngine.createPDF(file);
        media = new AMedia(getTitle(), "pdf", "application/pdf", file, true);
    } else if ("HTML".equals(previewType.getSelectedItem().getValue())) {
        String path = System.getProperty("java.io.tmpdir");
        String prefix = makePrefix(m_reportEngine.getName());
        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
        }
        File file = File.createTempFile(prefix, ".html", new File(path));
        m_reportEngine.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", this.getUuid()));
        media = new AMedia(getTitle(), "html", "text/html", file, false);
    } else if ("XLS".equals(previewType.getSelectedItem().getValue())) {
        String path = System.getProperty("java.io.tmpdir");
        String prefix = makePrefix(m_reportEngine.getName());
        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
        }
        File file = File.createTempFile(prefix, ".xls", new File(path));
        m_reportEngine.createXLS(file, AEnv.getLanguage(Env.getCtx()));
        media = new AMedia(getTitle(), "xls", "application/vnd.ms-excel", file, true);
    }
    iframe.setContent(media);
}
Also used : AMedia(org.zkoss.util.media.AMedia) Listitem(org.zkoss.zul.Listitem) File(java.io.File) HTMLExtension(org.adempiere.webui.report.HTMLExtension)

Aggregations

File (java.io.File)1 HTMLExtension (org.adempiere.webui.report.HTMLExtension)1 AMedia (org.zkoss.util.media.AMedia)1 Listitem (org.zkoss.zul.Listitem)1