本文整理汇总了Java中net.sf.jasperreports.engine.JasperFillManager类的典型用法代码示例。如果您正苦于以下问题:Java JasperFillManager类的具体用法?Java JasperFillManager怎么用?Java JasperFillManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JasperFillManager类属于net.sf.jasperreports.engine包,在下文中一共展示了JasperFillManager类的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: fillReport
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的package包/类
private static JasperPrint fillReport(JRFileVirtualizer virtualizer) throws JRException
{
long start = System.currentTimeMillis();
// Virtualization works only with in memory JasperPrint objects.
// All the operations will first fill the report and then export
// the filled object.
// creating the data source
JRDataSource dataSource = new JREmptyDataSource(1000);
// Preparing parameters
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
// filling the report
JasperPrint jasperPrint = JasperFillManager.fillReport("build/reports/VirtualizerReport.jasper", parameters, dataSource);
virtualizer.setReadOnly(true);
System.err.println("Filling time : " + (System.currentTimeMillis() - start));
return jasperPrint;
}
示例4: 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 );
}
示例5: loadReport
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的package包/类
public void loadReport(String reportName, ReportObject reportObject) {
logging = LoggingEngine.getInstance();
try {
final InputStream inputStream = ShowReport.class
.getResourceAsStream("/com/coder/hms/reportTemplates/" + reportName + ".jrxml");
JasperReport report = JasperCompileManager.compileReport(inputStream);
HashMap<String, Object> parameters = new HashMap<String, Object>();
List<ReportObject> list = new ArrayList<ReportObject>();
list.add(reportObject);
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(list);
JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, beanColDataSource);
final JRViewer viewer = new JRViewer(jasperPrint);
setType(Type.POPUP);
setResizable(false);
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
this.setTitle("Reservation [Report]");
this.setExtendedState(Frame.MAXIMIZED_BOTH);
this.setAlwaysOnTop(isAlwaysOnTopSupported());
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
this.setIconImage(Toolkit.getDefaultToolkit().
getImage(LoginWindow.class.getResource(LOGOPATH)));
this.setResizable(false);
getContentPane().add(viewer, BorderLayout.CENTER);
} catch (JRException e) {
logging.setMessage("JRException report error!");
}
}
示例6: 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();
}
}
示例7: showJasperManagerPDF
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的package包/类
@RequestMapping(value = "/hrms/showJasperManagerPDF", method = RequestMethod.GET)
public String showJasperManagerPDF(ModelMap model,
HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, JRException, NamingException {
usersList = loginService.getUserList();
AdminJasperBase dsUsers = new AdminJasperBase(usersList);
Map<String, Object> params = new HashMap<>();
params.put("users", usersList);
JasperReport jasperReport = getCompiledFile("JRUsers", request);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
params, dsUsers);
response.setContentType("application/x-pdf");
response.setHeader("Content-disposition",
"inline; filename=userList.pdf");
final OutputStream outStream = response.getOutputStream();
JasperExportManager.exportReportToPdfStream(jasperPrint, outStream);
return null;
}
示例8: fill
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的package包/类
/**
*
*/
public void fill() throws JRException
{
// Map<String, Object> parameters = new HashMap<>();
// parameters.put(JsonQueryExecuterFactory.JSON_DATE_PATTERN, "yyyy-MM-dd");
// parameters.put(JsonQueryExecuterFactory.JSON_NUMBER_PATTERN, "#,##0.##");
// parameters.put(JsonQueryExecuterFactory.JSON_LOCALE, Locale.ENGLISH);
// parameters.put(JRParameter.REPORT_LOCALE, Locale.US);
File[] files = getFiles(new File("build/reports"), "jasper");
for(int i = 0; i < files.length; i++)
{
File reportFile = files[i];
long start = System.currentTimeMillis();
JasperFillManager.fillReportToFile(reportFile.getAbsolutePath(), new HashMap<String, Object>());
System.err.println("Report : " + reportFile + ". Filling time : " + (System.currentTimeMillis() - start));
}
}
示例9: gerarDanfeNFe
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的package包/类
private static void gerarDanfeNFe(String url, List<String> emit, List<String> dest, List<String> nota, JRDataSource itens) {
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);
// Relatório compilado
JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
JasperPrint print = JasperFillManager.fillReport(report, map, itens);
JasperExportManager.exportReportToPdfFile(print, output);
} catch (JRException e) {
System.out.println("erro: "+e.getMessage());
}
}
示例10: gerarDanfeNfse
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的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());
}
}
示例11: 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;
}
}
示例12: getPinCard
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的package包/类
private JPanel getPinCard(){
try {
Map<String, Object> params = new HashMap<String, Object>(3);
params.put("library", BisisApp.getINIFile().getString("pincode", "library")); //$NON-NLS-1$
params.put("userid", mmbrship.getUserID()); //$NON-NLS-1$
params.put("name", userData.getFirstName() + " " + userData.getLastName());//$NON-NLS-1$
params.put("pincode", userData.getPinCode()); //$NON-NLS-1$
JasperPrint jp = JasperFillManager.fillReport(User.class.getResource(
"/com/gint/app/bisis4/client/circ/jaspers/pincode.jasper").openStream(), //$NON-NLS-1$
params, new JREmptyDataSource());
JRViewer jr = new JRViewer(jp);
return jr;
} catch (Exception e) {
e.printStackTrace();
log.error(e);
return null;
}
}
示例13: setPrint
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的package包/类
public static JasperPrint setPrint(SearchUsersTableModel table, String query){
try {
Map<String, Object> params = new HashMap<String, Object>(1);
params.put("upit", query);
JasperPrint jp = JasperFillManager.fillReport(SearchReport.class.getResource(
"/com/gint/app/bisis4/client/circ/jaspers/searchuser.jasper").openStream(),
params, new JRTableModelDataSource(table));
return jp;
} catch (Exception e) {
log.error(e);
return null;
}
}
示例14: fill
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的package包/类
/**
*
*/
public void fill() throws JRException
{
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("MaxOrderID", new Integer(12500));
File[] files = getFiles(new File("build/reports"), "jasper");
for(int i = 0; i < files.length; i++)
{
File reportFile = files[i];
long start = System.currentTimeMillis();
JasperFillManager.fillReportToFile(
reportFile.getAbsolutePath(),
new HashMap<String, Object>(parameters),
getDemoHsqldbConnection()
);
System.err.println("Report : " + reportFile + ". Filling time : " + (System.currentTimeMillis() - start));
}
}
示例15: fill
import net.sf.jasperreports.engine.JasperFillManager; //导入依赖的package包/类
/**
*
*/
public void fill() throws JRException
{
long start = System.currentTimeMillis();
Map<String, Object> parameters = new HashMap<String, Object>();
try
{
JRCsvDataSource xyds = new JRCsvDataSource(JRLoader.getLocationInputStream("data/xyDatasource.csv"), "UTF-8");
xyds.setRecordDelimiter("\r\n");
xyds.setUseFirstRowAsHeader(true);
parameters.put("xyDatasource", xyds);
}
catch (Exception e)
{
throw new JRException(e);
}
JasperFillManager.fillReportToFile("build/reports/XYChart.jasper", new HashMap<String, Object>(parameters), new JREmptyDataSource());
System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}