本文整理汇总了Java中net.sf.jasperreports.engine.JasperExportManager类的典型用法代码示例。如果您正苦于以下问题:Java JasperExportManager类的具体用法?Java JasperExportManager怎么用?Java JasperExportManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JasperExportManager类属于net.sf.jasperreports.engine包,在下文中一共展示了JasperExportManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generatePDF
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
public PDFResponseModel generatePDF(String fileName, String template, String bucketName,
Collection<?> items, Map<String, Object> parameters)
throws ClassNotFoundException, JRException, IOException {
JasperPrint jasperPrint;
InputStream inputStream = null;
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(items);
try {
inputStream = storageUtil.getInputStream(bucketName, template);
jasperPrint = JasperFillManager.fillReport(JasperCompileManager.compileReport(
inputStream), parameters, beanColDataSource);
byte[] pdfBytes = JasperExportManager.exportReportToPdf(jasperPrint);
return new PDFResponseModel(fileName, pdfBytes);
} catch (ClassNotFoundException | JRException | IOException e) {
xLogger.severe("Failed to generate PDF for file name - ", fileName, e);
throw e;
} finally {
if (inputStream != null) {
inputStream.close();
}
}
}
示例2: testInvoice
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
@Test
public void testInvoice(){
List<InvoiceItem> invoiceItems = new ArrayList<>();
int count = 1;
for (IDemandItem demandItem : getDemandItems()) {
InvoiceItem invoiceItem = new InvoiceItem();
invoiceItem.setItem(demandItem.getMaterialId().toString());
invoiceItem.setQuantity(demandItem.getQuantity().toString());
invoiceItem.setRecommended(demandItem.getRecommendedOrderQuantity().toString());
invoiceItem.setRemarks("Blah");
invoiceItem.setBatchId("AB/1234/56"+count);
invoiceItem.setExpiry("11/03/2020");
invoiceItem.setManufacturer("Serum");
invoiceItem.setBatchQuantity(BigDecimal.TEN.toPlainString());
invoiceItem.setSno(String.valueOf(count++));
invoiceItems.add(invoiceItem);
}
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(invoiceItems);
try {
Map<String, Object> hm = new HashMap<>();
JasperPrint jasperPrint = JasperFillManager.fillReport(
JasperCompileManager
.compileReport(Thread.currentThread().getContextClassLoader().getResourceAsStream(
"test_logistimo_invoice.jrxml")), hm, beanColDataSource);
JasperExportManager.exportReportToPdfFile(jasperPrint, "/tmp/logistimo_invoice.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: saveReport
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
* Saves a pre-compiled report into a file.
*
* @param jasperPrint
* JasperPrint object which contains a compiled report.
* @param expType
* The desired output type of the report.
* @param exportParameters
* Export parameters than can be added to configure the resulting report.
* @param target
* The file used to return the report.
* @throws JRException
* In case there is any error saving the report an exception is thrown with the error
* message.
*/
public static void saveReport(JasperPrint jasperPrint, ExportType expType,
Map<Object, Object> exportParameters, File target) throws JRException {
switch (expType) {
case CSV:
saveCsvReportToFile(jasperPrint, target);
break;
case HTML:
if (log.isDebugEnabled())
log.debug("JR: Print HTML");
saveHTMLReportToFile(jasperPrint, exportParameters, target);
break;
case PDF:
JasperExportManager.exportReportToPdfFile(jasperPrint, target.getAbsolutePath());
break;
case TXT:
saveTxtReportToFile(jasperPrint, target);
break;
case XLS:
saveExcelReportToFile(jasperPrint, exportParameters, target);
break;
case XML:
JasperExportManager.exportReportToXmlFile(jasperPrint, target.getAbsolutePath(), true);
break;
}
}
示例4: gerarDanfe
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
private static void gerarDanfe(String url, List<String> emit, List<String> dest, List<String> nota, JRDataSource itens, String qrcode){
try {
// Teste
//String compilado = System.getProperty("user.dir") + "/danfe_nfce_80.jasper";;
String output = "danfe.pdf";
map.put("emit", emit);
map.put("dest", dest);
map.put("nota", nota);
map.put("qrcode", qrcode);
// Relatório compilado
JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
//InputStream jasperStream = getClass().getResourceAsStream("/Foo.jasper");
//JasperReport report = (JasperReport) JRLoader.loadObject(jasperStream);
// Relatório nao compilado
//JasperReport report = JasperCompileManager.compileReport(jrxml);
JasperPrint print = JasperFillManager.fillReport(report, map, itens);
JasperExportManager.exportReportToPdfFile(print, output);
} catch (JRException e) {
System.out.println("erro: "+e.getMessage());
}
}
示例5: pdf
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
*
*/
public void pdf() throws JRException
{
File[] files = getFiles(new File("build/reports"), "jrprint");
for(int i = 0; i < files.length; i++)
{
File reportFile = files[i];
long start = System.currentTimeMillis();
String fileName = reportFile.getAbsolutePath();
JasperExportManager.exportReportToPdfFile(
fileName,
fileName.substring(0, fileName.indexOf(".jrprint")) + ".pdf"
);
System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
}
示例6: gerarDanfeNfse
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
private static void gerarDanfeNfse(String url, List<String> emit, List<String> dest, List<String> ser, List<String> nota, String xml, String logo) {
try {
// Teste
//String compilado = System.getProperty("user.dir") + "/danfe_nfce_80.jasper";;
String output = "danfe.pdf";
map.put("emit", emit);
map.put("dest", dest);
map.put("ser", ser);
map.put("nota", nota);
map.put("logo", logo);
// brasao
String brasao = Paths.get(System.getProperty("user.dir"), "danfe","brasao.png").toAbsolutePath().toString();
map.put("brasao", brasao);
// JrDataSource
JRDataSource jr = new JRXmlDataSource(xml);
// Relatório compilado
JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
JasperPrint print = JasperFillManager.fillReport(report, map, jr);
JasperExportManager.exportReportToPdfFile(print, output);
} catch (JRException e) {
System.out.println("erro: "+e.getMessage());
}
}
示例7: emitir
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
@Override
public void emitir() throws JRException {
try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) {
JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection);
this.relatorioGerado = print.getPages().size() > 0;
if(this.isRelatorioGerado()) {
String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome());
servletResponse.setHeader("Content-Disposition", attachment);
JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream());
}
} catch (IOException e) {
throw new RelatorioNaoExisteException(relatorio, e);
}
}
示例8: html
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
*
*/
public void html() throws JRException
{
long start = System.currentTimeMillis();
JasperExportManager.exportReportToHtmlFile("build/reports/XChartReport.jrprint");
System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
示例9: html
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
*
*/
public void html() throws JRException
{
long start = System.currentTimeMillis();
JasperExportManager.exportReportToHtmlFile("build/reports/FirstJasper.jrprint");
System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
示例10: xml
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
*
*/
public void xml() throws JRException
{
long start = System.currentTimeMillis();
JasperExportManager.exportReportToXmlFile("build/reports/LandscapeReport.jrprint", false);
System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
示例11: html
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
*
*/
public void html() throws JRException
{
long start = System.currentTimeMillis();
JasperExportManager.exportReportToHtmlFile("build/reports/JFreeChartReport.jrprint");
System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
示例12: xml
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
*
*/
public void xml() throws JRException
{
long start = System.currentTimeMillis();
JasperExportManager.exportReportToXmlFile("build/reports/UnicodeReport.jrprint", false);
System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
示例13: pdf
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
*
*/
public void pdf() throws JRException
{
File[] files = getFiles(new File("build/reports"), "jrprint");
for(int i = 0; i < files.length; i++)
{
File reportFile = files[i];
long start = System.currentTimeMillis();
JasperExportManager.exportReportToPdfFile(reportFile.getAbsolutePath());
System.err.println("Report : " + reportFile + ". PDF export time : " + (System.currentTimeMillis() - start));
}
}
示例14: html
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
*
*/
public void html() throws JRException
{
long start = System.currentTimeMillis();
JasperExportManager.exportReportToHtmlFile("build/reports/UnicodeReport.jrprint");
System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
示例15: xml
import net.sf.jasperreports.engine.JasperExportManager; //导入依赖的package包/类
/**
*
*/
public void xml() throws JRException
{
long start = System.currentTimeMillis();
JasperExportManager.exportReportToXmlFile("build/reports/BookReport.jrprint", false);
System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}