0

how to make summary in jasperreport ?

asked 2015-02-16 01:41:03 +0800

jwasky gravatar image jwasky
11 3

updated 2015-02-16 07:28:01 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9
https://github.com/chillw...

I want to make total of value,but i can't, can somebody help me?
I have this code in my setting_report.java file :

public void onClick$btn_cetak() throws ColumnBuilderException, ClassNotFoundException, JRException, IOException, InterruptedException {
    Set o = lst_avaliable_columns.getSelectedItems();
    int i = 1;
    for (Iterator j = o.iterator(); j.hasNext();) {
        String col2add;
        Listitem p = (Listitem) j.next();
        System.out.println(p.getLabel() + "LABEL E");
        //isi equalsIgnoreCase harus sama dengan columns_head, yang di zul
        if (p.getLabel().equalsIgnoreCase("No")) {
            frb.addColumn("No", "no", String.class.getName(), 30);
        } else if (p.getLabel().equalsIgnoreCase("NIK")) {
            frb.addColumn("NIK", "nik_karyawan", String.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Tanggal Akhir")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Tanggal Akhir", "tanggal_akhir", Date.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Lembur")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Lembur", "nilai_lembur", Long.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Tabungan")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Tabungan", "tabungan", Long.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Lain-lain")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Lain-lain", "dasoka", Long.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Jamsostek")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Jamsostek", "jamsostek", Long.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Tunjangan Kesehatan")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Tunjangan Kesehatan", "tunjangan_kesehatan", Long.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Tunjangan Hari Raya")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Tunjangan Hari Raya", "tunj_hr_raya", Long.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Bon Alat")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Bon Alat", "jml_angsuran", Long.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Koperasi")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Koperasi", "jml_koperasi", Long.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Jumlah Potongan")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Jumlah Potongan", "jml_pot", Long.class.getName(), 80);
        } else if (p.getLabel().equalsIgnoreCase("Gaji Total")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Gaji Total", "gaji_total", Long.class.getName(), 100);
        } else if (p.getLabel().equalsIgnoreCase("Gaji Kotor")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Gaji Kotor", "gaji_kotor", Long.class.getName(), 100);
        } else if (p.getLabel().equalsIgnoreCase("Gaji Bersih")) {
            System.out.println("LEWAT TANGGAL");
            frb.addColumn("Gaji Bersih", "gaji_bersih", Long.class.getName(), 100);
        } else if (p.getLabel().equalsIgnoreCase("Total")) {
            System.out.println("LEWAT TANGGAL");
            frb.addField("Total", "total");
        }
    }
    page.setOrientationPortrait(false);
    page.setHeight(768);
    page.setWidth(1080);

    frb.setTitle("Report Payroll Harian Karyawan PT.Mekar Armada Jaya");
    frb.setPrintBackgroundOnOddRows(false);

    frb.setPageSizeAndOrientation(page);
    frb.setMargins(20, 20, 10, 10);
    dr = frb.build();

    view = viewProsesGaji.getViewByQuery(txt_klausal.getValue());
    System.out.println(txt_klausal.getValue() + "KLAUSA L E");
    Map<Object, Object> map = new HashMap<Object, Object>();
    for (Iterator da = view.iterator(); da.hasNext();) {
        ProsesGaji kata = (ProsesGaji) da.next();
        kata.setNo(String.valueOf(i));
        map.put("no", kata.getNo());
        map.put("NIK", kata.getNik_karyawan());
        map.put("Tanggal Akhir", kata.getTanggal_akhir());
        map.put("Lembur", kata.getNilai_lembur());
        map.put("Tabungan", kata.getTabungan());
        map.put("Lain-lain", kata.getDasoka());
        map.put("Jamsostek", kata.getJamsostek());
        map.put("Tunjangan Kesehatan", kata.getTunjangan_kesehatan());
        map.put("Tunjangan Hari Raya ", kata.getTunj_hr_raya());
        map.put("Bon Alat", kata.getJml_angsuran());
        map.put("Koperasi", kata.getJml_koperasi());
        map.put("Jumlah Potongan", kata.getJml_pot());
        map.put("Gaji Total", kata.getGaji_total());
        map.put("Gaji Kotor", kata.getGaji_kotor());
        map.put("Gaji Bersih", kata.getGaji_bersih());
        i++;
    }

    JRDataSource ds = new JRBeanCollectionDataSource(view);
    ByteArrayOutputStream output = new ByteArrayOutputStream();

    Jasper = DynamicJasperHelper.generateJasperReport(dr, new ClassicLayoutManager(), new HashMap());

    JasperPrint jasperprint = null;

    jasperprint = JasperFillManager.fillReport(Jasper, new HashMap(), ds);

    if (rd_pdf.isChecked()) {
        JasperExportManager pdf = new JasperExportManager();
        pdf.exportReportToPdfStream(jasperprint, output);

        mediais = new ByteArrayInputStream(output.toByteArray());
        System.out.println("ada1");

        amedia = new AMedia("firstreport.pdf", "pdf", "application/pdf", mediais);

    } else if (rd_xls.isChecked()) {
        JExcelApiExporter xls = new JExcelApiExporter();
        xls.setParameter(JExcelApiExporterParameter.JASPER_PRINT, jasperprint);
        xls.setParameter(JExcelApiExporterParameter.OUTPUT_STREAM, output);
        xls.setParameter(JExcelApiExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
        xls.setParameter(JExcelApiExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
        xls.setParameter(JExcelApiExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
        xls.exportReport();
        mediais = new ByteArrayInputStream(output.toByteArray());
        System.out.println("ada1");

        amedia = new AMedia("FileFormatXls", "xls", "application/vnd-ms-excell", mediais);
    }
    final Window winDetail = (Window) Executions.createComponents(
            "/maj_zul/reportkaryawan/reportkaryawan/ViewReport.zul", null, null);
    report = (Iframe) winDetail.getFellow("report");
    report.setContent(amedia);
    winDetail.doModal();

    frb = new FastReportBuilder();
}
delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-02-16 01:41:03 +0800

Seen: 17 times

Last updated: Feb 16 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More