當前位置: 首頁>>代碼示例>>Java>>正文


Java JasperFillManager類代碼示例

本文整理匯總了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();
    }
  }
}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:25,代碼來源:JasperClient.java

示例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);
    }
}
 
開發者ID:douglasgusson,項目名稱:pitanga-system,代碼行數:41,代碼來源:PgRelatorioDAO.java

示例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;
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:24,代碼來源:VirtualizerApp.java

示例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 );
 
}
 
開發者ID:iuryamicussi,項目名稱:TrabalhoCrisParte2,代碼行數:27,代碼來源:ReportUtils.java

示例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!");
		}

	}
 
開發者ID:Coder-ACJHP,項目名稱:Hotel-Properties-Management-System,代碼行數:36,代碼來源:ShowReport.java

示例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();
  }


}
 
開發者ID:logistimo,項目名稱:logistimo-web-service,代碼行數:39,代碼來源:GenerateInvoiceTest.java

示例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;
}
 
開發者ID:PacktPublishing,項目名稱:Spring-MVC-Blueprints,代碼行數:24,代碼來源:AdminJasperReport.java

示例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));
		}
	}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:21,代碼來源:JsonQLDataSourceApp.java

示例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());
    }
}
 
開發者ID:juniortada,項目名稱:Java-Danfe,代碼行數:17,代碼來源:DanfeNfe.java

示例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());
    }
}
 
開發者ID:juniortada,項目名稱:Java-Danfe,代碼行數:24,代碼來源:DanfeNfe.java

示例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;
  }
}
 
開發者ID:unsftn,項目名稱:bisis-v4,代碼行數:25,代碼來源:User.java

示例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;
  }
}
 
開發者ID:unsftn,項目名稱:bisis-v4,代碼行數:21,代碼來源:User.java

示例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;
		}

	}
 
開發者ID:unsftn,項目名稱:bisis-v4,代碼行數:17,代碼來源:SearchReport.java

示例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));
	}
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:22,代碼來源:ChartsApp.java

示例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));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:22,代碼來源:XChartApp.java


注:本文中的net.sf.jasperreports.engine.JasperFillManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。