Java 类net.sf.jasperreports.engine.JRExporter 实例源码

项目:class-guard    文件:AbstractJasperReportsSingleFormatView.java   
/**
 * Perform rendering for a single Jasper Reports exporter, that is,
 * for a pre-defined output format.
 */
@Override
protected void renderReport(JasperPrint populatedReport, Map<String, Object> model, HttpServletResponse response)
        throws Exception {

    JRExporter exporter = createExporter();

    Map<JRExporterParameter, Object> mergedExporterParameters = getConvertedExporterParameters();
    if (!CollectionUtils.isEmpty(mergedExporterParameters)) {
        exporter.setParameters(mergedExporterParameters);
    }

    if (useWriter()) {
        renderReportUsingWriter(exporter, populatedReport, response);
    }
    else {
        renderReportUsingOutputStream(exporter, populatedReport, response);
    }
}
项目:PedidoVenda    文件:ExecutorRelatorio.java   
@Override
public void execute(Connection connection) throws SQLException {
    InputStream relatorioStream = this.getClass().getResourceAsStream(this.caminhoRelatorio);

    try {
        JasperPrint print = JasperFillManager.fillReport(relatorioStream, this.parametros, connection);

        this.relatorioGerado = print.getPages().size() > 0;

        if (this.relatorioGerado) {
            JRExporter exportador = new JRPdfExporter();
            exportador.setParameter(JRExporterParameter.OUTPUT_STREAM, this.response.getOutputStream());
            exportador.setParameter(JRExporterParameter.JASPER_PRINT, print);

            this.response.setContentType("application/pdf");
            this.response
                    .setHeader("Content-Disposition", "attachment; filename=\"" + this.nomeArquivoSaida + "\"");

            exportador.exportReport();
        }
    } catch (Exception e) {
        throw new SQLException("Erro ao executar relatorio " + this.caminhoRelatorio, e);
    }

}
项目:class-guard    文件:AbstractJasperReportsSingleFormatView.java   
/**
 * We need to write text to the response Writer.
 * @param exporter the JasperReports exporter to use
 * @param populatedReport the populated {@code JasperPrint} to render
 * @param response the HTTP response the report should be rendered to
 * @throws Exception if rendering failed
 */
protected void renderReportUsingWriter(
        JRExporter exporter, JasperPrint populatedReport, HttpServletResponse response) throws Exception {

    // Copy the encoding configured for the report into the response.
    String contentType = getContentType();
    String encoding = (String) exporter.getParameter(JRExporterParameter.CHARACTER_ENCODING);
    if (encoding != null) {
        // Only apply encoding if content type is specified but does not contain charset clause already.
        if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) {
            contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding;
        }
    }
    response.setContentType(contentType);

    // Render report into HttpServletResponse's Writer.
    JasperReportsUtils.render(exporter, populatedReport, response.getWriter());
}
项目:io-addon    文件:JasperRenderer.java   
/**
 * @throws JRException
 */
protected void exportReport(JRExporter exporter, JasperPrint jp, OutputStream os) throws JRException {
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);

    if (template.getJrExporterParameters() != null) {
        for (Entry<JRExporterParameter, Object> entry : template.getJrExporterParameters().entrySet()) {
            exporter.setParameter(entry.getKey(), entry.getValue());

        }
    }
    try {
        exporter.exportReport();

    } catch (JRException e) {
        throw new RuntimeException(e);
    }
}
项目:laboratorioSpring    文件:ReportJR.java   
/**
 */
public static byte[] printReport(final File filejrxml, Map<String, Object> param, final Connection conn, String reportFormat)
        throws IOException, NamingException, SQLException, JRException {

    final JasperPrint jasperPrintTemp = getJasperPrint(filejrxml, param, conn);

    JasperPrintManager.printReport(jasperPrintTemp, false);
    JRExporter exporter = getJREXporter(reportFormat);

    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, byteArrayOutputStream);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrintTemp);
    exporter.exportReport();

    return byteArrayOutputStream.toByteArray();
}
项目:laboratorioSpring    文件:ReportJR.java   
private static JRExporter getJREXporter(final String extension) {
        if ("pdf".equalsIgnoreCase(extension)) {
            JRPdfExporter exporter = new JRPdfExporter();
//          exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT, "this.print();");

            return exporter;

        } else if ("html".equalsIgnoreCase(extension)) {
            return new JRHtmlExporter();

        } else if ("xls".equalsIgnoreCase(extension)) {
             JRXlsExporter exporterXLS = new JRXlsExporter();                
             exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
             exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
             exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
             exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);

            return exporterXLS;

        } else if ("txt".equalsIgnoreCase(extension)) {
            return new JRTextExporter();
        } else if ("csv".equalsIgnoreCase(extension)) {
            return new JRCsvExporter();
        } else if ("docx".equalsIgnoreCase(extension)) {
            return new JRDocxExporter();
        }
        return null;
    }
项目:appverse-server    文件:ReportServiceImpl.java   
@Override
public byte[] generateExcel(List<ExcelSheetReportData> excelSheetsReportData)
        throws Exception {

    if (excelSheetsReportData == null || excelSheetsReportData.size() == 0) {
        throw new Exception("There are no data to make report.");
    }

    String[] sheetNamesArray = new String[excelSheetsReportData.size()];
    List<JasperPrint> jasperPrints = new ArrayList<JasperPrint>();
    int i = 0;
    for (ExcelSheetReportData excelSheetReportData : excelSheetsReportData) {
        sheetNamesArray[i] = excelSheetReportData.getSheetName();
        i++;

        JRDataSource reportDataSource = new JRMapCollectionDataSource(
                excelSheetReportData.getSheetData());
        JasperPrint jasperPrint = null;
        if (excelSheetReportData.getSheetReportLocation() != null
                && !excelSheetReportData.getSheetReportLocation()
                        .equals("")) {
            jasperPrint = JasperFillManager.fillReport(
                    excelSheetReportData.getSheetReportLocation(),
                    excelSheetReportData.getSheetParameters(),
                    reportDataSource);
        } else {
            jasperPrint = JasperFillManager.fillReport(
                    excelSheetReportData.getSheetReport(),
                    excelSheetReportData.getSheetParameters(),
                    reportDataSource);
        }
        jasperPrints.add(jasperPrint);
    }

    JasperPrint firstJasperPrint = jasperPrints.get(0);
    if (jasperPrints.size() > 1) {
        for (i = 1; i < jasperPrints.size(); i++) {
            List<JRPrintPage> additionalPages = new ArrayList<JRPrintPage>(
                    jasperPrints.get(i).getPages());
            int fistJasperPrintPages = firstJasperPrint.getPages().size();
            for (int count = 0; count < additionalPages.size(); count++) {
                firstJasperPrint.addPage(fistJasperPrintPages,
                        additionalPages.get(count));
            }
        }
    }

    JRExporter exporter = new JExcelApiExporter();
    exporter.setParameter(JRXlsExporterParameter.JASPER_PRINT,
            firstJasperPrint);
    exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE,
            Boolean.TRUE);
    exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,
            Boolean.FALSE);

    exporter.setParameter(
            JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
            Boolean.TRUE);
    exporter.setParameter(
            JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS,
            Boolean.TRUE);
    exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,
            Boolean.TRUE);
    exporter.setParameter(JRXlsExporterParameter.SHEET_NAMES,
            sheetNamesArray);
    exporter.setParameter(JExcelApiExporterParameter.IS_COLLAPSE_ROW_SPAN,
            Boolean.TRUE);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(32768);
    exporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM,
            outputStream);
    // exporter.setParameter(JRXlsExporterParameter.OUTPUT_FILE_NAME,
    // "C:/development/workspaces/jasper/report1.xls");
    exporter.exportReport();
    return outputStream.toByteArray();
}
项目:ireport-fork    文件:DefaultExporterFactory.java   
private void configureTextExporter(JRExporter exporter, SimpleJasperReportsContext context) {

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

        float floatVal = pref.getFloat(JRTextExporterParameter.PROPERTY_CHARACTER_HEIGHT, 0);
        if (floatVal > 0) context.setValue( JRTextExporterParameter.PROPERTY_CHARACTER_HEIGHT, floatVal+"");

        floatVal = pref.getFloat(JRTextExporterParameter.PROPERTY_CHARACTER_WIDTH, 0);
        if (floatVal > 0) context.setValue( JRTextExporterParameter.PROPERTY_CHARACTER_WIDTH, floatVal+"");

        int val = pref.getInt(JRTextExporterParameter.PROPERTY_PAGE_HEIGHT, 0);
        if (val > 0) context.setValue( JRTextExporterParameter.PROPERTY_PAGE_HEIGHT, ""+val);

        val = pref.getInt(JRTextExporterParameter.PROPERTY_PAGE_WIDTH, 0);
        if (val > 0) context.setValue( JRTextExporterParameter.PROPERTY_PAGE_WIDTH, ""+val);

        String s = null;
        if (pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.nothingBetweenPages", false))
        {
            exporter.setParameter( JRTextExporterParameter.BETWEEN_PAGES_TEXT, "");
        }
        else
        {
            s = pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.betweenPagesText", "");
            if (s.length() > 0) exporter.setParameter( JRTextExporterParameter.BETWEEN_PAGES_TEXT, s);
        }

        s = pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.txt.lineSeparator", "");
        if (s.length() > 0) exporter.setParameter( JRTextExporterParameter.LINE_SEPARATOR, s);

    }
项目:ireport-fork    文件:DefaultExporterFactory.java   
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)));
        }

    }
项目:ireport-fork    文件:DefaultExporterFactory.java   
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)));
        }

    }
项目:ireport-fork    文件:DefaultExporterFactory.java   
private void configureCsvExporter(JRExporter exporter, SimpleJasperReportsContext context) {

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

        context.setValue( JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER, pref.get(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER, jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER)));
        context.setValue( JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER, pref.get(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER, jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER)));
    }
项目:ireport-fork    文件:JRTxtExporterFactory.java   
public JRExporter createExporter(JasperReportsContext context) {
    JRTxtExporter exporter = new JRTxtExporter();

    // configuring the exporter...
    Preferences pref = IReportManager.getPreferences();


    int pageHeight = pref.getInt( "irtext.pageHeight", 0);
    if (pageHeight > 0)
    {
        exporter.setParameter( JRTxtExporterParameter.PAGE_ROWS, "" + pageHeight);
    }

    int pageWidth = pref.getInt( "irtext.pageWidth", 0);
    if (pageWidth > 0)
    {
        exporter.setParameter( JRTxtExporterParameter.PAGE_COLUMNS, "" + pageWidth);
    }

    boolean addFormFeed = pref.getBoolean("irtext.addFormFeed", true);
    exporter.setParameter( JRTxtExporterParameter.ADD_FORM_FEED, "" + addFormFeed);

    String bidi = pref.get("irtext.bidi", "");
    if (bidi.length() > 0)
    {
       exporter.setParameter( JRTxtExporterParameter.BIDI_PREFIX, bidi);

    }

    String displaywidthProviderFactory = pref.get("irtext.displaywidthProviderFactory", "");
    if (displaywidthProviderFactory.length() > 0)
    {
       exporter.setParameter( JRTxtExporterParameter.DISPLAY_WIDTH_PROVIDER_FACTORY, displaywidthProviderFactory);
    }

    return exporter;

}
项目:openeos    文件:DefaultExporterFactory.java   
@Override
public JRExporter createExporter(Map<String, ?> parameters) {
    try {
        return exporterClass.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
项目:openeos    文件:JasperReportsEngine.java   
private InputStream exportJasperPrint(JasperPrint jp, Map<String, Object> parameters, String mimeType) throws IOException {
    PipedInputStream pis = new PipedInputStream();
    PipedOutputStream pos = new PipedOutputStream(pis);
    JRExporter exporter = createExporter(mimeType, parameters);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, pos);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    createExporterThread(exporter, pos);
    return pis;
}
项目:openeos    文件:JasperReportsEngine.java   
private void createExporterThread(final JRExporter exporter, final PipedOutputStream pos) {
    Thread thread = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                exporter.exportReport();
                pos.close();
            } catch (JRException | IOException e) {
                Log.error("An error has occured while exporting report", e);
            }
        }
    }, THREAD_NAME);
    thread.start();
}
项目:openeos    文件:JasperReportsEngine.java   
private JRExporter createExporter(String mimeType, Map<String, Object> parameters) {
    ExporterFactory factory = exporterFactoryMap.get(mimeType);
    if (factory == null) {
        throw new UnsupportedOperationException();
    }
    return factory.createExporter(parameters);
}
项目:class-guard    文件:AbstractJasperReportsSingleFormatView.java   
/**
 * We need to write binary output to the response OutputStream.
 * @param exporter the JasperReports exporter to use
 * @param populatedReport the populated {@code JasperPrint} to render
 * @param response the HTTP response the report should be rendered to
 * @throws Exception if rendering failed
 */
protected void renderReportUsingOutputStream(
        JRExporter exporter, JasperPrint populatedReport, HttpServletResponse response) throws Exception {

    // IE workaround: write into byte array first.
    ByteArrayOutputStream baos = createTemporaryOutputStream();
    JasperReportsUtils.render(exporter, populatedReport, baos);
    writeToResponse(response, baos);
}
项目:enterprise-app    文件:AbstractReport.java   
protected void download(String filename, final JRExporter exporter) {
    StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        public InputStream getStream() {
            return new ByteArrayInputStream(getOutputStream(exporter).toByteArray());
        }

    }, filename);

    EnterpriseApplication.getInstance().getMainWindow().open(resource, "", true);
}
项目:konekti    文件:TemplateComponentReport.java   
protected void download(String filename, final JRExporter exporter) {
    StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        public InputStream getStream() {
            return new ByteArrayInputStream(getOutputStream(exporter).toByteArray());
        }

    }, filename, getApplication());

    getApplication().getMainWindow().open(resource, "_blank");
}
项目:konekti    文件:GridComponentReport.java   
protected void download(String filename, final JRExporter exporter) {
    StreamResource resource = new StreamResource(new StreamResource.StreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        public InputStream getStream() {
            return new ByteArrayInputStream(getOutputStream(exporter).toByteArray());
        }

    }, filename, getApplication());

    getApplication().getMainWindow().open(resource, "_blank");
}
项目:carcv    文件:BasicReportGenerator.java   
/**
 * Exports the report to a file in PDF format.
 *
 * @param filename file path of the exported report
 * @throws JRException if an error during exporting occurs
 */
public void exportFile(String filename) throws JRException {
    JRExporter exporter = new JRPdfExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, filledReportPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, filename);
    exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");

    exporter.exportReport();
}
项目:carcv    文件:BasicReportGenerator.java   
/**
 * Writes the report into the OutputStream in PDF format.
 *
 * @param filename filename of the exported report
 * @param out the output stream to print the report to
 * @throws JRException if an error during exporting occurs
 */
public void exportStream(String filename, OutputStream out) throws JRException {
    JRExporter exporter = new JRPdfExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, filledReportPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, filename);
    exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);

    exporter.exportReport();
}
项目:metasfresh    文件:JasperService.java   
@Override
public void setJrPrintExporter(final JRExporter jrExporter)
{
    printExporter = jrExporter;
}
项目:metasfresh    文件:AbstractJasperService.java   
@Override
public void setJrPrintExporter(final JRExporter jrExporter)
{
    throw new UnsupportedOperationException();
}
项目:metasfresh    文件:JasperServiceAdapter.java   
@Override
public void setJrPrintExporter(final JRExporter jrExporter)
{
    throw new UnsupportedOperationException();
}
项目:ireport-fork    文件:DefaultExporterFactory.java   
private void configureXlsExporter(JRExporter exporter, SimpleJasperReportsContext context) {

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

        context.setValue( JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE , pref.getBoolean(JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE, jrPropUtils.getBooleanProperty(JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE)));

        String password = pref.get(JExcelApiExporterParameter.PROPERTY_PASSWORD, jrPropUtils.getProperty(JExcelApiExporterParameter.PROPERTY_PASSWORD));
        if (password != null && password.length() > 0)
        {
            context.setValue( JExcelApiExporterParameter.PROPERTY_PASSWORD ,password);
        }

        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN)));

        System.out.println("Setting detect cell type to:" + pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE)));

        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE)));

        System.out.println("Setting detect cell type to ("+JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE+"):" + jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE));

        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED)));
        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BORDER , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BORDER, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BORDER)));
        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BACKGROUND , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BACKGROUND, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BACKGROUND)));
        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_IGNORE_GRAPHICS , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_GRAPHICS, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_GRAPHICS)));
        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_IMAGE_BORDER_FIX_ENABLED , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IMAGE_BORDER_FIX_ENABLED, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IMAGE_BORDER_FIX_ENABLED)));
        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET)));
        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS)));
        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS)));
        context.setValue( JRXlsAbstractExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND)));

        int maxRowsPerSheet = pref.getInt(JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET, jrPropUtils.getIntegerProperty(JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET));
        if (maxRowsPerSheet > 0)
        {
            context.setValue( JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET, ""+ maxRowsPerSheet);
        }
        if (pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.useSheetNames", false))
        {
            String sheetNames = pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.sheetNames", "");
            exporter.setParameter( JRXlsAbstractExporterParameter.SHEET_NAMES,  sheetNames.split("\n"));
        }

        // Add freeze options...
        String  col = pref.get(JRXlsExporter.PROPERTY_FREEZE_COLUMN, jrPropUtils.getProperty(JRXlsExporter.PROPERTY_FREEZE_COLUMN));
        if (col != null && col.length() > 0)
        {
            context.setValue( JRXlsExporter.PROPERTY_FREEZE_COLUMN, ""+col);
        }

//        String columnEdge = pref.get(JRXlsExporter.PROPERTY_FREEZE_COLUMN_EDGE, null);
//        if (columnEdge != null && columnEdge.length() > 0)
//        {
//            context.setValue( JRXlsExporter.PROPERTY_FREEZE_COLUMN_EDGE, columnEdge);
//        }

        // Add freeze options...
        int row = pref.getInt(JRXlsExporter.PROPERTY_FREEZE_ROW, jrPropUtils.getIntegerProperty(JRXlsExporter.PROPERTY_FREEZE_ROW,0));
        if (row > 0)
        {
            context.setValue( JRXlsExporter.PROPERTY_FREEZE_ROW, ""+row);
        }

//        String rowEdge = pref.get( JRXlsExporter.PROPERTY_FREEZE_ROW_EDGE, null);
//        if (rowEdge != null && rowEdge.length() > 0)
//        {
//            context.setValue( JRXlsExporter.PROPERTY_FREEZE_ROW_EDGE, pref.get(JRXlsExporter.PROPERTY_FREEZE_ROW_EDGE,  rowEdge));
//        }




    }
项目:ireport-fork    文件:DefaultExporterFactory.java   
private void configurePdfExporter(JRExporter exporter, SimpleJasperReportsContext context) {

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


        String pdfVersion = pref.get(JRPdfExporterParameter.PROPERTY_PDF_VERSION, null);
        if (pdfVersion != null && pdfVersion.length()==1) context.setValue( JRPdfExporterParameter.PROPERTY_PDF_VERSION  , ""+pdfVersion.charAt(0));

        boolean b = pref.getBoolean(JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS));
        context.setValue( JRPdfExporterParameter.PROPERTY_CREATE_BATCH_MODE_BOOKMARKS , new Boolean(b));

        context.setValue( JRPdfExporterParameter.PROPERTY_COMPRESSED , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_COMPRESSED, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_COMPRESSED))));
        context.setValue( JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_FORCE_LINEBREAK_POLICY))));
        context.setValue( JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_FORCE_SVG_SHAPES))));
        context.setValue( JRPdfExporterParameter.PROPERTY_TAGGED , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_TAGGED, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_TAGGED))));
        context.setValue( JRPdfExporterParameter.PROPERTY_ENCRYPTED , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_ENCRYPTED, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_ENCRYPTED))));
        context.setValue( JRPdfExporterParameter.PROPERTY_128_BIT_KEY , new Boolean(pref.getBoolean(JRPdfExporterParameter.PROPERTY_128_BIT_KEY, jrPropUtils.getBooleanProperty(JRPdfExporterParameter.PROPERTY_128_BIT_KEY))));

        if (pref.get("export.pdf.METADATA_AUTHOR", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_AUTHOR , pref.get("export.pdf.METADATA_AUTHOR", ""));
        }
        if (pref.get("export.pdf.METADATA_CREATOR", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_CREATOR , pref.get("export.pdf.METADATA_CREATOR", ""));
        }
        if (pref.get("export.pdf.METADATA_KEYWORDS", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_KEYWORDS , pref.get("export.pdf.METADATA_KEYWORDS", ""));
        }
        if (pref.get("export.pdf.METADATA_SUBJECT", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_SUBJECT , pref.get("export.pdf.METADATA_SUBJECT", ""));
        }
        if (pref.get("export.pdf.METADATA_TITLE", "").length() > 0)
        {
            exporter.setParameter( JRPdfExporterParameter.METADATA_TITLE , pref.get("export.pdf.METADATA_TITLE", ""));
        }
        if (pref.get("export.pdf.OWNER_PASSWORD", "").length() > 0)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_OWNER_PASSWORD , pref.get("export.pdf.OWNER_PASSWORD", ""));
        }
        if (pref.get("export.pdf.USER_PASSWORD", "").length() > 0)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_USER_PASSWORD , pref.get("export.pdf.USER_PASSWORD", ""));
        }
        if (pref.get("export.pdf.TAG_LANGUAGE", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_TAG_LANGUAGE)) != null)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_TAG_LANGUAGE ,pref.get("export.pdf.TAG_LANGUAGE", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_TAG_LANGUAGE)));
        }
        if (pref.get("export.pdf.PDF_JAVASCRIPT", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT)) != null)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT ,pref.get("export.pdf.PDF_JAVASCRIPT", jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDF_JAVASCRIPT)));
        }
        if (pref.getInt("export.pdf.PERMISSIONS",0) != 0)
        {
            exporter.setParameter(JRPdfExporterParameter.PERMISSIONS ,pref.getInt("export.pdf.PERMISSIONS",0));
        }


        String pdfa = pref.get(JRPdfExporterParameter.PROPERTY_PDFA_CONFORMANCE,jrPropUtils.getProperty(JRPdfExporterParameter.PDFA_CONFORMANCE_NONE));
        if (pdfa != null)
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_PDFA_CONFORMANCE ,pdfa);
        }

        String pdfaICC = pref.get(JRPdfExporterParameter.PROPERTY_PDFA_ICC_PROFILE_PATH,jrPropUtils.getProperty(JRPdfExporterParameter.PROPERTY_PDFA_ICC_PROFILE_PATH));
        if (pdfaICC != null && !pdfaICC.equals(""))
        {
            context.setValue( JRPdfExporterParameter.PROPERTY_PDFA_ICC_PROFILE_PATH ,pdfaICC);
        }
    }
项目:ireport-fork    文件:JRTxtExporterFactory.java   
public JRExporter createExporter() {
    return createExporter(null);
}
项目:openeos    文件:DefaultExporterFactory.java   
public DefaultExporterFactory(Class<? extends JRExporter> exporterClass) {
    if (!JRExporter.class.isAssignableFrom(exporterClass)) {
        throw new IllegalArgumentException();
    }
    this.exporterClass = exporterClass;
}
项目:class-guard    文件:JasperReportsXlsView.java   
@Override
protected JRExporter createExporter() {
    return new JRXlsExporter();
}
项目:class-guard    文件:JasperReportsHtmlView.java   
@Override
protected JRExporter createExporter() {
    return new JRHtmlExporter();
}
项目:class-guard    文件:JasperReportsCsvView.java   
@Override
protected JRExporter createExporter() {
    return new JRCsvExporter();
}
项目:class-guard    文件:JasperReportsPdfView.java   
@Override
protected JRExporter createExporter() {
    return new JRPdfExporter();
}
项目:geomajas-project-server    文件:JasperReportsDocxView.java   
@Override
protected JRExporter createExporter() {
    return new JRDocxExporter();
}
项目:geomajas-project-server    文件:JasperReportsOdtView.java   
@Override
protected JRExporter createExporter() {
    return new JROdtExporter();
}
项目:lams    文件:JasperReportsUtils.java   
/**
 * Render the supplied {@code JasperPrint} instance using the
 * supplied {@code JRAbstractExporter} instance and write the results
 * to the supplied {@code Writer}.
 * <p>Make sure that the {@code JRAbstractExporter} implementation
 * you supply is capable of writing to a {@code Writer}.
 * @param exporter the {@code JRAbstractExporter} to use to render the report
 * @param print the {@code JasperPrint} instance to render
 * @param writer the {@code Writer} to write the result to
 * @throws JRException if rendering failed
 */
public static void render(JRExporter exporter, JasperPrint print, Writer writer)
        throws JRException {

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
    exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, writer);
    exporter.exportReport();
}
项目:lams    文件:JasperReportsUtils.java   
/**
 * Render the supplied {@code JasperPrint} instance using the
 * supplied {@code JRAbstractExporter} instance and write the results
 * to the supplied {@code OutputStream}.
 * <p>Make sure that the {@code JRAbstractExporter} implementation you
 * supply is capable of writing to a {@code OutputStream}.
 * @param exporter the {@code JRAbstractExporter} to use to render the report
 * @param print the {@code JasperPrint} instance to render
 * @param outputStream the {@code OutputStream} to write the result to
 * @throws JRException if rendering failed
 */
public static void render(JRExporter exporter, JasperPrint print, OutputStream outputStream)
        throws JRException {

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
    exporter.exportReport();
}
项目:ireport-fork    文件:DefaultExporterFactory.java   
private void configureXmlExporter(JRExporter exporter, SimpleJasperReportsContext context) {

        Preferences pref = IReportManager.getPreferences();

        //context.setValue( JRCsvExporterParameter.FIELD_DELIMITER, pref.get(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER, jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_FIELD_DELIMITER)));
        //context.setValue( JRCsvExporterParameter.RECORD_DELIMITER, pref.get(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER, jrPropUtils.getProperty(JRCsvExporterParameter.PROPERTY_RECORD_DELIMITER)));
    }
项目:class-guard    文件:JasperReportsUtils.java   
/**
 * Render the supplied {@code JasperPrint} instance using the
 * supplied {@code JRAbstractExporter} instance and write the results
 * to the supplied {@code Writer}.
 * <p>Make sure that the {@code JRAbstractExporter} implementation
 * you supply is capable of writing to a {@code Writer}.
 * @param exporter the {@code JRAbstractExporter} to use to render the report
 * @param print the {@code JasperPrint} instance to render
 * @param writer the {@code Writer} to write the result to
 * @throws JRException if rendering failed
 */
public static void render(JRExporter exporter, JasperPrint print, Writer writer)
        throws JRException {

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
    exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, writer);
    exporter.exportReport();
}
项目:class-guard    文件:JasperReportsUtils.java   
/**
 * Render the supplied {@code JasperPrint} instance using the
 * supplied {@code JRAbstractExporter} instance and write the results
 * to the supplied {@code OutputStream}.
 * <p>Make sure that the {@code JRAbstractExporter} implementation you
 * supply is capable of writing to a {@code OutputStream}.
 * @param exporter the {@code JRAbstractExporter} to use to render the report
 * @param print the {@code JasperPrint} instance to render
 * @param outputStream the {@code OutputStream} to write the result to
 * @throws JRException if rendering failed
 */
public static void render(JRExporter exporter, JasperPrint print, OutputStream outputStream)
        throws JRException {

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
    exporter.exportReport();
}