• หน้าแรก
  • หลักสูตร
  • บทความ
  • ร้านค้า
  • ติดต่อเรา
    มีคำถามเกี่ยวกับ odoo ?
    (02) 4302475
    info@odoothaidev.com
    Login
    Odoothaidev - We are Odoo professional in Thailand
    • หน้าแรก
    • หลักสูตร
    • บทความ
    • ร้านค้า
    • ติดต่อเรา

      Jasper Server & Server

      • บ้าน
      • บล็อก
      • Jasper Server & Server
      • ใช้ jasper reports ออกรายงานเป็นไฟล์ pdf

      ใช้ jasper reports ออกรายงานเป็นไฟล์ pdf

      • โพสโดย admin
      • หมวดหมู่ Jasper Server & Server
      • วันที่ กรกฎาคม 27, 2019
      • ความคิดเห็น 0 ความคิดเห็น
      • แท็ก jasper reports

      มีงานต้องออก report โดยใช้ Jasper Reports เป็นตัวช่วย เวลาออกแบบก็ไปใช้ iReport แล้วเราจะได้ไฟล์ .jrxml เสร็จแล้ว จะเอามาเขียนโค้ดเพื่อโหลดไฟล์ และส่ง connection ของ database ให้ jasper Reports ทำการ export รายงานออกมาเป็น pdf
      โค้ด java ที่ลอง

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      import net.sf.jasperreports.engine.*;
      import net.sf.jasperreports.engine.design.JasperDesign;
      import net.sf.jasperreports.engine.xml.JRXmlLoader;
      import net.sf.jasperreports.engine.export.*;
      import java.util.*;
      import java.sql.*;
      public class TestJasper {
          public static void main(String[] args) {
              JasperReport jasperReport;
              JasperPrint jasperPrint;
              JasperDesign jasperDesign;
              Connection conn = null;
              
              Map parameters = new HashMap();
              try {
                  Class.forName("com.mysql.jdbc.Driver");
                  conn = DriverManager.getConnection("jdbc:mysql://localhost/database?useUnicode=true&characterEncoding=UTF-8&user=root&password=password");
                              // โหลดไฟล์ jrxml
                  jasperDesign = JRXmlLoader.load("/home/iporsut/Sourcecode/report3.jrxml");
                              // คอมไพล์ report จะได้ไฟล์ report3.jasper
                  jasperReport = JasperCompileManager.compileReport(jasperDesign);
                              // ส่ง parameters กับ connection ของ database ให้ jasper ทำการ fill report
                  jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,conn);
                              // export report ออกไปเป็นไฟล์ demo.pdf
                  JasperExportManager.exportReportToPdfFile(jasperPrint,"/home/iporsut/demo.pdf");
              }catch (JRException e) {
                  e.printStackTrace();
              }
              catch (ClassNotFoundException ex) {System.err.println(ex.getMessage());}
                  catch (SQLException ex) {System.err.println(ex.getMessage());}
                  
              finally
              {
                  if (conn != null)
                  {
                      try {conn.close();}
                      catch (Exception ignored) {}
                  }
              }
          }
      }

      แท็ก:jasper reports

      • Share:
      อวตารของผู้เขียน
      admin

      โพสต์ก่อนหน้า

      Django คืออะไร ดีจังโก้ คือโปรแกรม สำหรับพัฒนา web application ซึ่งเขียนในภาษา python
      กรกฎาคม 27, 2019

      โพสต์ถัดไป

      Jasper Report ในหลากหลายภาษา
      กรกฎาคม 27, 2019

      คุณอาจชอบ

      How to add report datasource in ireport designer
      9 กันยายน, 2019

      This article is related to jasper report …

      How to create a report in jasper ireport
      9 กันยายน, 2019

      In this article I will show you how to c …

      How to add serial number in jasper ireport
      9 กันยายน, 2019

      In this article you will learn how to di …

      ทิ้งคำตอบไว้

      อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น ช่องข้อมูลจำเป็นถูกทำเครื่องหมาย *

      ค้นหาบทความ

      หมวดหมู่

      หมวดหมู่

      • Accounting
      • Adobe XD
      • API
      • Blog
      • Business
      • Buttons
      • CRM
      • Custom Fields
      • Design / Branding
      • Django
      • Ecommerce
      • ERP
      • ERP Flow
      • Express
      • Flectra
      • Form View
      • Frontend
      • Github
      • Github
      • Grant Chart
      • Header
      • iReport
      • Jasper Server & Server
      • Jaspersoft Studio
      • Java
      • JSON-RPC
      • Lazada
      • Linux
      • MLM
      • MRP
      • Nignx Proxy
      • NodeJS
      • Odoo 10
      • Odoo 12 Module
      • Odoo 13
      • Odoo 14 Development
      • Odoo 16
      • Odoo 8
      • Odoo 9
      • Odoo API
      • Odoo Certification
      • Odoo Developer
      • Odoo Ebook
      • Odoo Enterprise
      • Odoo ERP
      • Odoo Event
      • Odoo Implement
      • Odoo Inventory
      • Odoo Report
      • Odoo Security
      • Odoo V15
      • Open Source
      • Open-office
      • OpenERP 7.0
      • PhantomJS
      • Postgres SQL
      • Programming Language
      • Project Management
      • Python
      • Python3
      • Qweb
      • Reporting ระบบรายงาน
      • RML Report
      • Search View and Filters
      • Social Network
      • Statusbar
      • Ubuntu
      • Uncategorized
      • Voip & Call Center
      • Warehouse Management
      • WMS
      • Woocommerce
      • Workflow
      • XML-RPC
      • การ Implement
      • การเก็บข้อมูล Pre-Requirement
      • การเตรียมตัวเพื่อใช้งาน erp
      • ความรู้ด้านการตลาด CRM
      • ธีมเว็บไซต์ Odoo
      • ธุรกิจบริการ
      • ธุรกิจประเภทจัดอบรมสัมมนา
      • ธุรกิจสิ่งพิมพ์
      • นักพัฒนา
      • ประเภทธุรกิจที่เหมาะกับ Odoo
      • ระบบบัญชี
      • ระบบเคลม
      • ลิขสิทธิ์ – License
      Introduction LearnPress – LMS plugin

      Introduction LearnPress – LMS plugin

      Free
      From Zero to Hero with Nodejs

      From Zero to Hero with Nodejs

      Free
      Learn Python – Interactive Python

      Learn Python – Interactive Python

      $69.00

      บทความล่าสุด

      Securing Odoo logins with fail2ban
      22พ.ค.2023
      V16 Planned Date of Tasks are invisible.
      12ก.พ.2023
      Odoo Implement Methodology
      29พ.ย.2022
      (02) 430-2475
      info@odoothaidev.com
      Facebook Twitter Google-plus Pinterest

      Odoothaidev by OdooTeaM.

      • Privacy
      • Terms
      • Sitemap
      • Purchase

      เข้าสู่ระบบด้วยบัญชีเว็บไซต์ของคุณ

      ลืมรหัสผ่าน?

      Click to Copy