本文整理汇总了Java中net.sf.jasperreports.engine.JRExporterParameter类的典型用法代码示例。如果您正苦于以下问题:Java JRExporterParameter类的具体用法?Java JRExporterParameter怎么用?Java JRExporterParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JRExporterParameter类属于net.sf.jasperreports.engine包,在下文中一共展示了JRExporterParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: export
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
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();
}
}
}
示例2: renderReport
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
/**
* 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);
}
}
示例3: export
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
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();
}
}
}
示例4: export
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
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();
}
}
}
示例5: export
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的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();
}
}
}
示例6: export
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
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();
}
}
}
示例7: export
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
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();
}
}
}
示例8: export
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
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();
}
}
}
示例9: export
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
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();
}
}
}
示例10: print
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
/**
*
*/
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;
}
示例11: printPageToImage
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
/**
*
*/
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;
}
示例12: exportToXML
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
/**
* @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;
}
示例13: exportToXML
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
/**
* @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;
}
示例14: exportToXML
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
/**
* @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;
}
示例15: exportToXML
import net.sf.jasperreports.engine.JRExporterParameter; //导入依赖的package包/类
/**
* @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;
}