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

项目: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);
    }
}
项目:bdf2    文件:JrpxmlExporter.java   
public void export(HttpServletRequest req, HttpServletResponse res)
        throws Exception {
    res.setContentType("text/xml");
    res.setHeader("Content-Disposition", "inline; filename=\"file.jrpxml\"");
    JRXmlExporter exporter = new JRXmlExporter(DefaultJasperReportsContext.getInstance());
    JasperPrint jasperPrint=this.getJasperPrint(req);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
    //exporter.setParameter(JRExporterParameter.START_PAGE_INDEX, Integer.valueOf(1));
    OutputStream ouputStream = res.getOutputStream();
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
    try {
        exporter.exportReport();
    } catch (JRException e) {
        throw new ServletException(e);
    } finally {
        if (ouputStream != null) {
            ouputStream.flush();
            ouputStream.close();
        }
    }
}
项目:bdf2    文件:RtfExporter.java   
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
    String fileName=this.getExportFileName(req);
    fileName+=".rtf";
    res.setContentType("application/octet-stream");
    res.setHeader("Connection", "close");
    res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
    JRRtfExporter exporter = new JRRtfExporter(DefaultJasperReportsContext.getInstance());
    JasperPrint jasperPrint=this.getJasperPrint(req);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
    OutputStream ouputStream = res.getOutputStream();
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
    try {
        exporter.exportReport();
    } catch (JRException e) {
        throw new ServletException(e);
    } finally {
        if (ouputStream != null) {
            ouputStream.flush();
            ouputStream.close();
        }
    }
}
项目:bdf2    文件:HtmlExporter.java   
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();
        }
    }
}
项目:bdf2    文件:PptxExporter.java   
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
    String fileName=this.getExportFileName(req);
    fileName+=".pptx";
    res.setContentType("application/octet-stream");
    res.setHeader("Connection", "close");
    res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
    JRPptxExporter exporter = new JRPptxExporter(DefaultJasperReportsContext.getInstance());
    JasperPrint jasperPrint=this.getJasperPrint(req);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
    OutputStream ouputStream = res.getOutputStream();
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
    try {
        exporter.exportReport();
    } catch (JRException e) {
        throw new ServletException(e);
    } finally {
        if (ouputStream != null) {
            ouputStream.flush();
            ouputStream.close();
        }
    }
}
项目:bdf2    文件:PdfExporter.java   
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
    String fileName=this.getExportFileName(req);
    fileName+=".pdf";
    res.setContentType("application/octet-stream");
    res.setHeader("Connection", "close");
    res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
    JRPdfExporter exporter = new JRPdfExporter(DefaultJasperReportsContext.getInstance());
    JasperPrint jasperPrint=this.getJasperPrint(req);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
    OutputStream ouputStream = res.getOutputStream();
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
    try {
        exporter.exportReport();
    } catch (JRException e) {
        throw new ServletException(e);
    } finally {
        if (ouputStream != null) {
            ouputStream.flush();
            ouputStream.close();
        }
    }
}
项目:bdf2    文件:CsvExporter.java   
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
    String fileName=this.getExportFileName(req);
    fileName+=".csv";
    res.setContentType("application/octet-stream");
    res.setHeader("Connection", "close");
    res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
    JRCsvExporter exporter = new JRCsvExporter(DefaultJasperReportsContext.getInstance());
    JasperPrint jasperPrint=this.getJasperPrint(req);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
    OutputStream ouputStream = res.getOutputStream();
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
    try {
        exporter.exportReport();
    } catch (JRException e) {
        throw new ServletException(e);
    } finally {
        if (ouputStream != null) {
            ouputStream.flush();
            ouputStream.close();
        }
    }
}
项目:bdf2    文件:DocxExporter.java   
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
    String fileName=this.getExportFileName(req);
    fileName+=".docx";
    res.setContentType("application/octet-stream");
    res.setHeader("Connection", "close");
    res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
    JRDocxExporter exporter = new JRDocxExporter(DefaultJasperReportsContext.getInstance());
    JasperPrint jasperPrint=this.getJasperPrint(req);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
    OutputStream ouputStream = res.getOutputStream();
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
    try {
        exporter.exportReport();
    } catch (JRException e) {
        throw new ServletException(e);
    } finally {
        if (ouputStream != null) {
            ouputStream.flush();
            ouputStream.close();
        }
    }
}
项目:bdf2    文件:XlsExporter.java   
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception {
    String fileName=this.getExportFileName(req);
    fileName+=".xls";
    res.setContentType("application/octet-stream");
    res.setHeader("Connection", "close");
    res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\"");
    JRXlsExporter exporter = new JRXlsExporter(DefaultJasperReportsContext.getInstance());
    JasperPrint jasperPrint=this.getJasperPrint(req);
    exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
    OutputStream ouputStream = res.getOutputStream();
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
    try {
        exporter.exportReport();
    } catch (JRException e) {
        throw new ServletException(e);
    } finally {
        if (ouputStream != null) {
            ouputStream.flush();
            ouputStream.close();
        }
    }
}
项目:openbravo-pos    文件:JRPrinterAWT300.java   
/**
 *
 */
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
{
    if (Thread.currentThread().isInterrupted())
    {
        throw new PrinterException("Current thread interrupted.");
    }

    pageIndex += pageOffset;

    if ( pageIndex < 0 || pageIndex >= jasperPrint.getPages().size() )
    {
        return Printable.NO_SUCH_PAGE;
    }

    try
    {
        JRGraphics2DExporter exporter = new JRGraphics2DExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
        exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, graphics);
        exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
        exporter.exportReport();
    }
    catch (JRException e)
    {
        e.printStackTrace();
        throw new PrinterException(e.getMessage());
    }

    return Printable.PAGE_EXISTS;
}
项目:openbravo-pos    文件:JRPrinterAWT300.java   
/**
 *
 */
private Image printPageToImage(int pageIndex, float zoom) throws JRException
{
    Image pageImage = new BufferedImage(
        (int)(jasperPrint.getPageWidth() * zoom) + 1,
        (int)(jasperPrint.getPageHeight() * zoom) + 1,
        BufferedImage.TYPE_INT_RGB
        );

    JRGraphics2DExporter exporter = new JRGraphics2DExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
    exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics());
    exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
    exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoom));
    exporter.exportReport();

    return pageImage;
}
项目:wifepos    文件:JRPrinterAWT300.java   
/**
 *
 */
private Image printPageToImage(int pageIndex, float zoom) throws JRException
{
    Image pageImage = new BufferedImage(
        (int)(jasperPrint.getPageWidth() * zoom) + 1,
        (int)(jasperPrint.getPageHeight() * zoom) + 1,
        BufferedImage.TYPE_INT_RGB
        );

    JRGraphics2DExporter exporter = new JRGraphics2DExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
    exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics());
    exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
    exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoom));
    exporter.exportReport();

    return pageImage;
}
项目:micro-Blagajna    文件:JRPrinterAWT300.java   
/**
 *
 */
private Image printPageToImage(int pageIndex, float zoom) throws JRException
{
    Image pageImage = new BufferedImage(
        (int)(jasperPrint.getPageWidth() * zoom) + 1,
        (int)(jasperPrint.getPageHeight() * zoom) + 1,
        BufferedImage.TYPE_INT_RGB
        );

    JRGraphics2DExporter exporter = new JRGraphics2DExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
    exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics());
    exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
    exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoom));
    exporter.exportReport();

    return pageImage;
}
项目: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);
    }

}
项目:metasfresh    文件:AbstractJasperService.java   
@Override
public byte[] exportToPdf(final JasperPrint jasperPrint)
{
    final JRPdfExporter exporter = new JRPdfExporter();

    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
    exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF8");

    try
    {
        exporter.exportReport();
    }
    catch (JRException e)
    {
        throw new AdempiereException("Cannot create PDF from " + jasperPrint, e);
    }

    return outputStream.toByteArray();
}
项目:omr    文件:OMRModelTest.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
protected byte[] exportToXML(JasperPrint jp) throws JazzOMRJRException {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目:omr    文件:ParticipationHelperWS.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
private byte[] exportToXML(JasperPrint jp) {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzOMRRuntimeException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzOMRRuntimeException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目:omr    文件:ParticipationHelperWS.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
private byte[] exportToXML(JasperPrint jp) {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目:omr    文件:ParticipationHelper.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
protected byte[] exportToXML(JasperPrint jp)  {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目:omr    文件:OMRModelTest.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
protected byte[] exportToXML(JasperPrint jp) throws JazzOMRJRException {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目:omr    文件:ParticipationHelper.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
protected byte[] exportToXML(JasperPrint jp)  {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目:omr    文件:OMRModelTest.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
protected byte[] exportToXML(JasperPrint jp) throws JazzOMRJRException {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目: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);
    }
}
项目:omr    文件:ParticipationHelper.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
protected byte[] exportToXML(JasperPrint jp)  {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目:omr    文件:ParticipationHelper.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
protected byte[] exportToXML(JasperPrint jp)  {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzRuntimeException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目:omr    文件:OMRModelTest.java   
/**
 * @param jp
 * @return
 * @throws JazzOMRJRException
 * @throws JRException
 */
protected byte[] exportToXML(JasperPrint jp) throws JazzOMRJRException {

    ByteArrayOutputStream baosXML = new ByteArrayOutputStream();

    JRXmlExporter exporter = new JRXmlExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baosXML);
    exporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE);
    try {
        exporter.exportReport();
    } catch (JRException e1) {
        throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e1);
    }

    byte[] xmlBytes = null;
    try {
        baosXML.flush();
        xmlBytes = baosXML.toByteArray();
        baosXML.close();
    } catch (IOException e) {
        throw new JazzOMRJRException("Erro ao tentar exportar relatorio", e);
    }

    return xmlBytes;
}
项目: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();
}
项目:PDFReporter-Studio    文件:ScriptletApp.java   
/**
 *
 */
public void xls() throws JRException
{
    long start = System.currentTimeMillis();
    File sourceFile = new File("build/reports/ScriptletReport.jrprint");

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

    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xls");

    JRXlsExporter exporter = new JRXlsExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());
    exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);

    exporter.exportReport();

    System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
项目:PDFReporter-Studio    文件:ScriptletApp.java   
/**
 *
 */
public void jxl() throws JRException
{
    long start = System.currentTimeMillis();
    File sourceFile = new File("build/reports/ScriptletReport.jrprint");

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

    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".jxl.xls");

    JExcelApiExporter exporter = new JExcelApiExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());
    exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);

    exporter.exportReport();

    System.err.println("XLS creation time : " + (System.currentTimeMillis() - start));
}
项目:PDFReporter-Studio    文件:ScriptletApp.java   
/**
 *
 */
public void ods() throws JRException
{
    long start = System.currentTimeMillis();
    File sourceFile = new File("build/reports/ScriptletReport.jrprint");

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

    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".ods");

    JROdsExporter exporter = new JROdsExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());
    exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);

    exporter.exportReport();

    System.err.println("ODS creation time : " + (System.currentTimeMillis() - start));
}
项目:PDFReporter-Studio    文件:ScriptletApp.java   
/**
 *
 */
public void xlsx() throws JRException
{
    long start = System.currentTimeMillis();
    File sourceFile = new File("build/reports/ScriptletReport.jrprint");

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

    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".xlsx");

    JRXlsxExporter exporter = new JRXlsxExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());
    exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);

    exporter.exportReport();

    System.err.println("XLSX creation time : " + (System.currentTimeMillis() - start));
}
项目:unicenta    文件:JRPrinterAWT300.java   
/**
 *
 */
private Image printPageToImage(int pageIndex, float zoom) throws JRException
{
    Image pageImage = new BufferedImage(
        (int)(jasperPrint.getPageWidth() * zoom) + 1,
        (int)(jasperPrint.getPageHeight() * zoom) + 1,
        BufferedImage.TYPE_INT_RGB
        );

    JRGraphics2DExporter exporter = new JRGraphics2DExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
    exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics());
    exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
    exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoom));
    exporter.exportReport();

    return pageImage;
}
项目:class-guard    文件:AbstractJasperReportsView.java   
/**
 * Convert the supplied parameter value into the actual type required by the
 * corresponding {@link JRExporterParameter}.
 * <p>The default implementation simply converts the String values "true" and
 * "false" into corresponding {@code Boolean} objects, and tries to convert
 * String values that start with a digit into {@code Integer} objects
 * (simply keeping them as String if number conversion fails).
 * @param parameter the parameter key
 * @param value the parameter value
 * @return the converted parameter value
 */
protected Object convertParameterValue(JRExporterParameter parameter, Object value) {
    if (value instanceof String) {
        String str = (String) value;
        if ("true".equals(str)) {
            return Boolean.TRUE;
        }
        else if ("false".equals(str)) {
            return Boolean.FALSE;
        }
        else if (str.length() > 0 && Character.isDigit(str.charAt(0))) {
            // Looks like a number... let's try.
            try {
                return new Integer(str);
            }
            catch (NumberFormatException ex) {
                // OK, then let's keep it as a String value.
                return str;
            }
        }
    }
    return value;
}
项目:class-guard    文件:AbstractJasperReportsViewTests.java   
@Ignore
public void ignoreTestOverrideExporterParameters() throws Exception {
    AbstractJasperReportsView view = getView(COMPILED_REPORT);

    if (!(view instanceof AbstractJasperReportsSingleFormatView) || !((AbstractJasperReportsSingleFormatView) view).useWriter()) {
        return;
    }

    String characterEncoding = "UTF-8";
    String overiddenCharacterEncoding = "ASCII";

    Map parameters = new HashMap();
    parameters.put(JRExporterParameter.CHARACTER_ENCODING, characterEncoding);

    view.setExporterParameters(parameters);
    view.convertExporterParameters();

    Map model = getModel();
    model.put(JRExporterParameter.CHARACTER_ENCODING, overiddenCharacterEncoding);

    view.render(model, this.request, this.response);

    assertEquals(overiddenCharacterEncoding, this.response.getCharacterEncoding());
}
项目:class-guard    文件:AbstractJasperReportsViewTests.java   
public void testWithCharacterEncoding() throws Exception {
    AbstractJasperReportsView view = getView(COMPILED_REPORT);

    if (!(view instanceof AbstractJasperReportsSingleFormatView) || !((AbstractJasperReportsSingleFormatView) view).useWriter()) {
        return;
    }

    String characterEncoding = "UTF-8";

    Map parameters = new HashMap();
    parameters.put(JRExporterParameter.CHARACTER_ENCODING, characterEncoding);

    view.setExporterParameters(parameters);
    view.convertExporterParameters();

    view.render(getModel(), this.request, this.response);
    assertEquals(characterEncoding, this.response.getCharacterEncoding());
}
项目:io-addon    文件:JasperRenderer.java   
/**
 * Xls export.
 *
 * @param jp
 * @param os
 */
protected void exportXls(JasperPrint jp, OutputStream os) {
    // Create a JRXlsExporter instance
    JRXlsExporter exporter = new JRXlsExporter();

    // Here we assign the parameters jp and baos to the exporter
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);

    // TODO add Excel specific parameters
    exporter.setParameter(JRXlsAbstractExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
    exporter.setParameter(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
    exporter.setParameter(JRXlsAbstractExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);

    try {
        exporter.exportReport();

    } catch (JRException e) {
        throw new RuntimeException(e);
    }
}
项目:carbon-commons    文件:PdfReport.java   
/**
 * generate a ByteArrayOutputStream from given JasperPrint object for the PDF report
 *
 * @param jasperPrint transform to pdf report
 * @return reporting ByteArrayOutputStream
 * @throws ReportingException when the JasperPrint null
 * @throws JRException
 * @throws IOException
 */
public ByteArrayOutputStream generatePdfReport(JasperPrint jasperPrint) throws JRException, ReportingException {

    ByteArrayOutputStream pdfOutputStream = new ByteArrayOutputStream();
    if (jasperPrint == null) {
        throw new ReportingException("jasperPrint null, can't convert to  PDF report");
    }
    try {

        JRPdfExporter jrPdfExporter = new JRPdfExporter();
        jrPdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        jrPdfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, pdfOutputStream);
        jrPdfExporter.exportReport();

    } catch (JRException e) {
        throw new JRException("Error occurred exporting PDF report ", e);
    }
    return pdfOutputStream;
}
项目:carbon-commons    文件:XMLReport.java   
public ByteArrayOutputStream generateXmlReport(JasperPrint jasperPrint)
        throws JRException, ReportingException {
    ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream();
    if(jasperPrint==null){
        throw new ReportingException("jasperPrint null, can't convert to  XML report");
    }
    JRXmlExporter jrXmlExporter = new JRXmlExporter();
    jrXmlExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    jrXmlExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, xmlOutputStream);
    try {
        jrXmlExporter.exportReport();

    } catch (JRException e) {
        throw new JRException("Error occurred exporting PDF report ", e);
    }
    return xmlOutputStream;
}
项目:gnvc-ims    文件:ReportGenerator.java   
/**
 * Configure path for getting template and store exported report file.
 */
private void configureExportPath() {
    File f;
    StringBuffer targetBuff = new StringBuffer();
    //collectCustomProperties();

    targetBuff.append(EXPORTED_PATH).append(sp);

    targetBuff.append(getTemplateName()).append(".").append(getOutputSuffix());// .toLowerCase());
    EXPORTED_FILENAME = targetBuff.toString();

    f = new File(EXPORTED_FILENAME).getParentFile();
    if (!f.exists()) {
        f.mkdirs();
    }

    setExportParameter(JRExporterParameter.OUTPUT_FILE_NAME, EXPORTED_FILENAME);
    ReportProperty.setExportedFileName(EXPORTED_FILENAME);
}