本文整理汇总了Java中net.sf.jasperreports.engine.JasperFillManager.fillReport方法的典型用法代码示例。如果您正苦于以下问题:Java JasperFillManager.fillReport方法的具体用法?Java JasperFillManager.fillReport怎么用?Java JasperFillManager.fillReport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.jasperreports.engine.JasperFillManager
的用法示例。
在下文中一共展示了JasperFillManager.fillReport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generatePDF
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的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: gerarRelatorioClientesSintetico
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
@Override
public JasperViewer gerarRelatorioClientesSintetico() {
Connection connection = PostgreSQLDAOFactory.getConnection();
try {
Statement stm = connection.createStatement();
String query = "SELECT\n"
+ " cl.\"cod_cliente\" AS codigo,\n"
+ " cl.\"nome_cliente\" AS nome,\n"
+ " ci.\"nome_cidade\" AS nome_cidade,\n"
+ " ci.\"sigla_uf\" AS sigla,\n"
+ " cl.\"telefone\" AS telefone\n"
+ "FROM\n"
+ " \"cliente\" cl INNER JOIN \"cidade\" ci "
+ "ON cl.\"cod_cidade\" = ci.\"cod_cidade\"\n"
+ "ORDER BY\n"
+ " cl.nome_cliente ASC";
ResultSet rs = stm.executeQuery(query);
JRResultSetDataSource jrRS = new JRResultSetDataSource(rs);
InputStream fonte
= PgRelatorioDAO.class.getResourceAsStream(
"/br/com/pitanga/report/RelatorioClientesSintetico.jrxml");
JasperReport report = JasperCompileManager.compileReport(fonte);
JasperPrint print = JasperFillManager.fillReport(report, null, jrRS);
JasperViewer jv = new JasperViewer(print, false);
return jv;
} catch (JRException | SQLException ex) {
throw new DAOException(
"Falha ao gerar relatório sintético "
+ "de clientes em JDBCRelatorioDAO", ex);
}
}
示例3: openReport
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
/**
* Abre um relatório usando um datasource genérico.
*
* @param titulo Título usado na janela do relatório.
* @param inputStream InputStream que contém o relatório.
* @param parametros Parâmetros utilizados pelo relatório.
* @param dataSource Datasource a ser utilizado pelo relatório.
* @throws JRException Caso ocorra algum problema na execução do relatório
*/
public static void openReport(
String titulo,
InputStream inputStream,
Map parametros,
JRDataSource dataSource ) throws JRException {
/*
* Cria um JasperPrint, que é a versão preenchida do relatório,
* usando um datasource genérico.
*/
JasperPrint print = JasperFillManager.fillReport(
inputStream, parametros, dataSource );
// abre o JasperPrint em um JFrame
viewReportFrame( titulo, print );
}
示例4: testInvoice
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的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();
}
}
示例5: getRevers
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
private JPanel getRevers(){
try {
Map<String, Object> params = new HashMap<String, Object>(3);
params.put("korisnik", lending.getUser()); //$NON-NLS-1$
params.put("korisnik-adresa", userData.getAddressRevers()); //$NON-NLS-1$
params.put("broj-indeksa", userData.getIndexNoRevers());
params.put("biblioteka", Cirkulacija.getApp().getEnvironment().getReversLibraryName()); //$NON-NLS-1$
params.put("adresa", Cirkulacija.getApp().getEnvironment().getReversLibraryAddress()); //$NON-NLS-1$
params.put("bibliotekar", Cirkulacija.getApp().getLibrarian().getIme()+" "+Cirkulacija.getApp().getLibrarian().getPrezime()); //$NON-NLS-1$ //$NON-NLS-2$
// budzotina zbog subotice (ako je vrednostu u ReversHeight = 1 stampace se inverntarni broj u zaglavlju reversa
params.put("zaglavlje-broj", Cirkulacija.getApp().getEnvironment().getReversHeight());
JasperPrint jp = JasperFillManager.fillReport(User.class.getResource(
"/com/gint/app/bisis4/client/circ/jaspers/revers.jasper").openStream(), //$NON-NLS-1$
params, new JRTableModelDataSource(lending.getReversTableModel()));
JRViewer jr = new JRViewer(jp);
return jr;
} catch (Exception e) {
e.printStackTrace();
log.error(e);
return null;
}
}
示例6: showReport
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
/**
* Prikazuje ucitani izvestaj.
*/
public static void showReport(String xml,String fileName, Report report) {
HashMap<String, Object> params = new HashMap<String, Object>();
try {
for (ReportParam p : report.getReportSettings().getParams()){
if(p.getName().compareToIgnoreCase("subjasper")==0){
JasperReport subreport = (JasperReport) JRLoader.loadObject(ReportUtils.class
.getResource(p.getValue()).openStream());
params.put("subjasper", subreport);
}else{
params.put(p.getName(), p.getValue());
}
}
DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance(); //dodato zbog jaxena
JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.xpath.executer.factory", "net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory");
params.put("period", getPeriod(fileName));
JRXmlDataSource dataSource = new JRXmlDataSource(XMLUtils
.getDocumentFromString(xml), "/report/item");
JasperPrint jp = JasperFillManager.fillReport(Report.class.getResource(
report.getJasper()).openStream(), params, dataSource);
BisisApp.getMainFrame().addReportFrame(report.getName(), jp);
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例7: imprimirPolizasPorCompania
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@MemberOrder(sequence = "6")
public Blob imprimirPolizasPorCompania(
@ParameterLayout(named="Compania: ") final Compania companiaSeleccionada) throws JRException, IOException {
PolizaPorCompaniaDataSource datasource = new PolizaPorCompaniaDataSource();
for (Poliza pol : polizaRepository.buscarPorCompania(companiaSeleccionada)){
PolizaPorCompaniaReporte reportePolizaPorCompania =new PolizaPorCompaniaReporte();
reportePolizaPorCompania.setPolizasCliente(pol.getPolizaCliente().toString());
reportePolizaPorCompania.setPolizasCompania(pol.getPolizaCompania().getCompaniaNombre());
reportePolizaPorCompania.setPolizaNumero(pol.getPolizaNumero());
reportePolizaPorCompania.setPolizaFechaVigencia(pol.getPolizaFechaVigencia());
reportePolizaPorCompania.setPolizaFechaVencimiento(pol.getPolizaFechaVencimiento());
reportePolizaPorCompania.setPolizaFechaEmision(pol.getPolizaFechaEmision());
reportePolizaPorCompania.setPolizaImporteTotal(pol.getPolizaImporteTotal());
datasource.addParticipante(reportePolizaPorCompania);
}
String jrxml = "PolizasPorCompania.jrxml";
String nombreArchivo = "Listado de polizas por compania"+" "+companiaSeleccionada.getCompaniaNombre()+" ";
InputStream input = ReporteRepository.class.getResourceAsStream(jrxml);
JasperDesign jd = JRXmlLoader.load(input);
JasperReport reporte = JasperCompileManager.compileReport(jd);
Map<String, Object> parametros = new HashMap<String, Object>();
parametros.put("compania", companiaSeleccionada.getCompaniaNombre());
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, parametros, datasource);
return ReporteRepository.imprimirReporteLista(jasperPrint, jrxml, nombreArchivo);
}
示例8: raporti
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
private void raporti(){
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
JasperReport jreport = JasperCompileManager.compileReport(raporti);
JasperPrint jprint = JasperFillManager.fillReport(jreport, new HashedMap(), conn);
JasperViewer.viewReport(jprint, false);
conn.close();
}catch (Exception ex){ex.printStackTrace();}
}
});
btnRaport.setOnAction(e -> t.start());
}
示例9: imprimirFacturacionAnualPorCompania
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@MemberOrder(sequence = "5")
public Blob imprimirFacturacionAnualPorCompania() throws JRException, IOException {
FacturacionDataSource datasource = new FacturacionDataSource();
for (FacturacionCompaniasViewModel fac : facturacionRepository.facturacion()){
FacturacionReporte facturacionCompania =new FacturacionReporte();
facturacionCompania.setCompania(fac.getCompania().getCompaniaNombre().toString());
facturacionCompania.setPrimaTotal(fac.getPrimaTotal());
datasource.addParticipante(facturacionCompania);
}
String jrxml = "FacturacionCompanias.jrxml";
String nombreArchivo = "Facturacion companias ";
InputStream input = ReporteRepository.class.getResourceAsStream(jrxml);
JasperDesign jd = JRXmlLoader.load(input);
JasperReport reporte = JasperCompileManager.compileReport(jd);
Map<String, Object> parametros = new HashMap<String, Object>();
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, parametros, datasource);
return ReporteRepository.imprimirReporteLista(jasperPrint, jrxml, nombreArchivo);
}
示例10: prepareReport
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
public static JasperPrint prepareReport(String reportpath) throws Exception {
HashMap<String, Object> params = new HashMap<>();
File f = new File("reports");
String SUBREPORT_DIR = f.getAbsolutePath() + "\\";
params.put("SUBREPORT_DIR", SUBREPORT_DIR);
JasperReport jr = JasperCompileManager.compileReport(reportpath);
return JasperFillManager.fillReport(jr, params, con);
}
示例11: imprimirClientesActivos
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@MemberOrder(sequence = "3")
public Blob imprimirClientesActivos() throws JRException, IOException {
ClientesActivosDataSource datasource = new ClientesActivosDataSource();
for (Cliente cli : clientesRepository.listarActivos()){
ClientesActivosReporte reporteClientesActivos=new ClientesActivosReporte();
reporteClientesActivos.setClienteNombre(cli.getClienteNombre());
reporteClientesActivos.setClienteApellido(cli.getClienteApellido());
reporteClientesActivos.setClienteDni(cli.getClienteDni());
reporteClientesActivos.setClienteTipoDocumento(cli.getClienteTipoDocumento().toString());
reporteClientesActivos.setPersonaMail(cli.getPersonaMail());
reporteClientesActivos.setPersonaTelefono(cli.getPersonaTelefono());
datasource.addParticipante(reporteClientesActivos);
}
String jrxml = "ClientesActivos.jrxml";
String nombreArchivo = "Listado Clientes Activos ";
InputStream input = ReporteRepository.class.getResourceAsStream(jrxml);
JasperDesign jd = JRXmlLoader.load(input);
JasperReport reporte = JasperCompileManager.compileReport(jd);
Map<String, Object> parametros = new HashMap<String, Object>();
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, parametros, datasource);
return ReporteRepository.imprimirReporteLista(jasperPrint, jrxml, nombreArchivo);
}
示例12: emitir
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的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);
}
}
示例13: getPrint
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
private JPanel getPrint(){
try{
JasperPrint jp = JasperFillManager.fillReport(
User.class.getResource(
"/com/gint/app/bisis4/client/circ/jaspers/empty.jasper").openStream(),
null, new JREmptyDataSource());
jr = new JRViewer(jp);
return jr;
}catch (Exception e){
e.printStackTrace();
return null;
}
}
示例14: doFillReport
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
/**
* Fill the given report using the given JDBC DataSource and model.
*/
private JasperPrint doFillReport(JasperReport report, Map<String, Object> model, DataSource ds) throws Exception {
// Use the JDBC DataSource.
if (logger.isDebugEnabled()) {
logger.debug("Filling report using JDBC DataSource [" + ds + "]");
}
Connection con = ds.getConnection();
try {
return JasperFillManager.fillReport(report, model, con);
}
finally {
try {
con.close();
}
catch (Throwable ex) {
logger.debug("Could not close JDBC Connection", ex);
}
}
}
示例15: gerarRelatorioValorMedio
import net.sf.jasperreports.engine.JasperFillManager; //导入方法依赖的package包/类
@Override
public JasperViewer gerarRelatorioValorMedio() {
Connection connection = PostgreSQLDAOFactory.getConnection();
try {
Statement stm = connection.createStatement();
String query = "SELECT\n"
+ " p.cod_produto,\n"
+ " p.descricao_produto,\n"
+ " AVG(iv.valor_unitario) AS valor_medio\n"
+ " FROM produto p\n"
+ " INNER JOIN item_venda iv ON iv.cod_produto = p.cod_produto\n"
+ " GROUP BY (p.cod_produto);";
ResultSet rs = stm.executeQuery(query);
JRResultSetDataSource jrRS = new JRResultSetDataSource(rs);
InputStream fonte
= PgRelatorioDAO.class.getResourceAsStream(
"/br/com/pitanga/report/RelatorioValorMedioVenda.jrxml");
JasperReport report = JasperCompileManager.compileReport(fonte);
JasperPrint print = JasperFillManager.fillReport(report, null, jrRS);
JasperViewer jv = new JasperViewer(print, false);
return jv;
} catch (SQLException | JRException ex) {
throw new DAOException("Falha ao gerar relatório de valor médio!", ex);
}
}