Java 类net.sf.jasperreports.engine.JasperFillManager 实例源码

项目:logistimo-web-service    文件:JasperClient.java   
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();
    }
  }
}
项目:pitanga-system    文件:PgRelatorioDAO.java   
@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);
    }
}
项目:jasperreports    文件:VirtualizerApp.java   
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;
}
项目:TrabalhoCrisParte2    文件:ReportUtils.java   
/**
 * 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 );

}
项目:Hotel-Properties-Management-System    文件:ShowReport.java   
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!");
        }

    }
项目:logistimo-web-service    文件:GenerateInvoiceTest.java   
@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();
  }


}
项目:Automekanik    文件:ShikoPunetPunetoret.java   
private void krijoRaport(String pnt){
    btnRaporti.setOnAction(e -> {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
                    HashMap hm = new HashMap();
                    hm.put("Folderi", folderi);
                    hm.put("punetori", pnt);
                    JasperReport jreport = JasperCompileManager.compileReport(raportiPunetor);
                    JasperPrint jprint = JasperFillManager.fillReport(jreport, hm, conn);
                    JasperViewer.viewReport(jprint, false);
                    conn.close();
                }catch (Exception ex){ex.printStackTrace();}
            }
        });
        t.start();
    });
}
项目:Spring-MVC-Blueprints    文件:AdminJasperReport.java   
@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;
}
项目:spring4-understanding    文件:AbstractJasperReportsView.java   
/**
 * 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);
        }
    }
}
项目:jasperreports    文件:JsonQLDataSourceApp.java   
/**
     *
     */
    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));
        }
    }
项目:Java-Danfe    文件:DanfeNfe.java   
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());
    }
}
项目:Java-Danfe    文件:DanfeNfe.java   
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());
    }
}
项目:bisis-v4    文件:User.java   
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;
  }
}
项目:bisis-v4    文件:User.java   
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;
  }
}
项目:bisis-v4    文件:SearchReport.java   
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;
        }

    }
项目:jasperreports    文件:ChartsApp.java   
/**
 *
 */
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));
    }
}
项目:jasperreports    文件:XChartApp.java   
/**
 *
 */
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));
}
项目:jasperreports    文件:ListApp.java   
/**
 *
 */
public void fill() throws JRException
{
    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(), 
            null, 
            getDemoHsqldbConnection()
            );
        System.err.println("Report : " + reportFile + ". Filling time : " + (System.currentTimeMillis() - start));
    }
}
项目:jasperreports    文件:XlsDataSourceApp.java   
/**
 *
 */
public void fill() throws JRException
{
    long start = System.currentTimeMillis();
    //Preparing parameters
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("ReportTitle", "Address Report");
    parameters.put("DataFile", "XlsDataSource.data.xls - XLS data source");
    Set<String> states = new HashSet<String>();
    states.add("Active");
    states.add("Trial");
    parameters.put("IncludedStates", states);

    JasperFillManager.fillReportToFile("build/reports/XlsDataSourceReport.jasper", parameters, getDataSource());
    System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:XlsFeaturesApp.java   
/**
 *
 */
public void fill() throws JRException
{
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("ReportTitle", "Customers Report");
    parameters.put("Customers", "Customers");
    parameters.put("ReportDate", new Date());
    parameters.put("DataFile", "CsvDataSource.txt - CSV query executer");

    File[] files = getFiles(new File("build/reports"), "jasper");
    for(int i = 0; i< files.length; i++)
    {
        long start = System.currentTimeMillis();
        File sourceFile = files[i];
        JasperFillManager.fillReportToFile(sourceFile.getPath(), new HashMap<String, Object>(parameters));
        System.err.println("Report : " + sourceFile + ". Filling time : " + (System.currentTimeMillis() - start));
    }
}
项目:jasperreports    文件:CrosstabApp.java   
/**
 *
 */
public void fill() throws JRException
{
    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(), 
            null, 
            getDemoHsqldbConnection()
            );
        System.err.println("Report : " + reportFile + ". Filling time : " + (System.currentTimeMillis() - start));
    }
}
项目:jasperreports    文件:ChartCustomizersApp.java   
/**
 *
 */
public void fill() throws JRException
{
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("legendWidth", "10");
    parameters.put("legendHeight", "10");

    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) 
            );
        System.err.println("Report : " + reportFile + ". Filling time : " + (System.currentTimeMillis() - start));
    }
}
项目:jasperreports    文件:HttpDataAdapterApp.java   
/**
 *
 */
public void fill() throws JRException
{
    File[] files = getFiles(new File("build/reports"), "jasper");
    for(int i = 0; i < files.length; i++)
    {
        File reportFile = files[i];
        long start = System.currentTimeMillis();
        String fileName = reportFile.getAbsolutePath();
        JasperFillManager.fillReportToFile(
            fileName, 
            fileName.substring(0, fileName.lastIndexOf(".jasper")) + ".jrprint",
            null
            );
        System.err.println(reportFile.getName() + " filling time : " + (System.currentTimeMillis() - start));
    }
}
项目:jasperreports    文件:HibernateApp.java   
/**
 *
 */
public void fill() throws JRException
{
    Session session = createSession();
    Transaction transaction = session.beginTransaction();

    Map<String, Object> params = getParameters(session);

    File[] files = 
        new File[]{
            new File("build/reports/AddressesReport.jasper"),
            new File("build/reports/HibernateQueryReport.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>(params));
        System.err.println("Report : " + reportFile + ". Filling time : " + (System.currentTimeMillis() - start));
    }

    transaction.rollback();
    session.close();
}
项目:jasperreports    文件:EjbqlApp.java   
/**
 *
 */
public void fill() throws JRException
{
    long start = System.currentTimeMillis();
    // create entity manager factory for connection with database
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu1", new HashMap<Object, Object>());
    EntityManager em = emf.createEntityManager();

    try
    {
        Map<String, Object> parameters = getParameters(em);

        JasperFillManager.fillReportToFile("build/reports/JRMDbReport.jasper", parameters);

        em.close();

        System.err.println("Filling time : " + (System.currentTimeMillis() - start));
    }
    finally
    {
        if (em.isOpen())
            em.close();
        if (emf.isOpen())
            emf.close();
    }
}
项目:jasperreports    文件:I18nApp.java   
/**
     *
     */
    public void fill() throws JRException
    {
        long start = System.currentTimeMillis();
        Locale locale = chooseLocale();
        if (locale != null)
        {
//                  Object[] aw = new Object[] {new Double(1000000.45), "$", "Ferrari", new Integer(20),new Integer(88)};
            Map<String, Object> parameters = new HashMap<String, Object>();
            parameters.put("number", new Double(1234567 + Math.random()));
//                  parameters.put("array", aw);
            parameters.put(JRParameter.REPORT_LOCALE, locale);
            JasperFillManager.fillReportToFile("build/reports/I18nReport.jasper", parameters, new JREmptyDataSource());
            System.err.println("Filling time : " + (System.currentTimeMillis() - start));
        }
    }
项目:jasperreports    文件:BatchExportApp.java   
/**
 *
 */
public void fill() throws JRException
{
    long start = System.currentTimeMillis();
    JasperFillManager.fillReportToFile(
        "build/reports/Report1.jasper",
        null, 
        new JREmptyDataSource(2)
        );
    JasperFillManager.fillReportToFile(
        "build/reports/Report2.jasper",
        null, 
        new JREmptyDataSource(2)
        );
    JasperFillManager.fillReportToFile(
        "build/reports/Report3.jasper",
        null, 
        new JREmptyDataSource(2)
        );
    System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
项目:TrabalhoCrisParte2    文件:ReportUtils.java   
/**
 * Abre um relatório usando uma conexão como datasource.
 *
 * @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 conexao Conexão utilizada para a execução da query.
 * @throws JRException Caso ocorra algum problema na execução do relatório
 */
public static void openReport(
        String titulo,
        InputStream inputStream,
        Map parametros,
        Connection conexao ) throws JRException {

    /*
     * Cria um JasperPrint, que é a versão preenchida do relatório,
     * usando uma conexão.
     */
    JasperPrint print = JasperFillManager.fillReport(
            inputStream, parametros, conexao );

    // abre o JasperPrint em um JFrame
    viewReportFrame( titulo, print );

}
项目:java-swing-template    文件:ReportsModel.java   
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);
}
项目:Proyecto2017Seguros    文件:ReporteMenu.java   
@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);

}
项目:Proyecto2017Seguros    文件:ReporteMenu.java   
@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);

   }
项目:Proyecto2017Seguros    文件:ReporteMenu.java   
@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);
   }
项目:Automekanik    文件:ShikoKonsumatoret.java   
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());
}
项目:Automekanik    文件:ShikoPunetoret.java   
private void raporti(){
    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 HashMap(), conn);
                JasperViewer.viewReport(jprint, false);
                conn.close();
            }catch (Exception ex){ex.printStackTrace();}
        }
    }).start();
}
项目:pitanga-system    文件:Relatorio.java   
public void gerarRelatorioEstados(List<Uf> estados) throws JRException {

        InputStream fonte = Relatorio.class.getResourceAsStream("/br/com/pitanga/report/RelatorioEstados.jrxml");

        JasperReport report = JasperCompileManager.compileReport(fonte);
        JasperPrint print = JasperFillManager.fillReport(report, null, new JRBeanCollectionDataSource(estados));
        JasperViewer.viewReport(print, false);
    }
项目:spring4-understanding    文件:JasperReportsUtilsTests.java   
@Test
public void renderWithWriter() throws Exception {
    StringWriter writer = new StringWriter();
    JasperPrint print = JasperFillManager.fillReport(getReport(), getParameters(), getDataSource());
    JasperReportsUtils.render(new JRHtmlExporter(), print, writer);
    String output = writer.getBuffer().toString();
    assertHtmlOutputCorrect(output);
}
项目:spring4-understanding    文件:JasperReportsUtilsTests.java   
@Test
public void renderWithOutputStream() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    JasperPrint print = JasperFillManager.fillReport(getReport(), getParameters(), getDataSource());
    JasperReportsUtils.render(new JRPdfExporter(), print, os);
    byte[] output = os.toByteArray();
    assertPdfOutputCorrect(output);
}
项目:ESIPC    文件:Menu.java   
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
    // TODO add your handling code here:
     try {
        conectar cc= new conectar();

        JasperReport reportes=JasperCompileManager.compileReport("Estudiante.jrxml");
        JasperPrint print=JasperFillManager.fillReport(reportes, null, cc.conexion());
        JasperViewer.viewReport(print);

    } catch (Exception e) {
        System.out.printf(e.getMessage());
    }
}
项目:ESIPC    文件:Menu.java   
private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem13ActionPerformed
    // TODO add your handling code here:
    try {
        conectar cc= new conectar();

        JasperReport reportes=JasperCompileManager.compileReport("Factura.jrxml");
        JasperPrint print=JasperFillManager.fillReport(reportes, null, cc.conexion());
        JasperViewer.viewReport(print);

    } catch (Exception e) {
        System.out.printf(e.getMessage());
    }

}
项目:ESIPC    文件:Menu.java   
private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem14ActionPerformed
    // TODO add your handling code here:
   try {
        conectar cc= new conectar();

        JasperReport reportes=JasperCompileManager.compileReport("Curso.jrxml");
        JasperPrint print=JasperFillManager.fillReport(reportes, null, cc.conexion());
        JasperViewer.viewReport(print);

    } catch (Exception e) {
        System.out.printf(e.getMessage());
    }
}