• Courses
    Introduction LearnPress – LMS plugin

    Introduction LearnPress – LMS plugin

    Free
    อ่านเพิ่มเติม
  • Features
    • Membership
    • Portfolio
    • About Us
    • FAQs
    • Sidebar Shop
    • 404 Page
  • Events
  • Gallery
  • Blog
  • Contact
  • Shop
    มีคำถามเกี่ยวกับ odoo ?
    (063) 5525296
    info@odoothaidev.com
    Login
    Odoothaidev - We are Odoo professional in ThailandOdoothaidev - We are Odoo professional in Thailand
    • Courses
      Introduction LearnPress – LMS plugin

      Introduction LearnPress – LMS plugin

      Free
      อ่านเพิ่มเติม
    • Features
      • Membership
      • Portfolio
      • About Us
      • FAQs
      • Sidebar Shop
      • 404 Page
    • Events
    • Gallery
    • Blog
    • Contact
    • Shop

      Jasper Server & Server

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

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

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

      มีงานต้องออก 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

      • แบ่งปัน:
      อวตารของผู้แต่ง
      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 …

      ทิ้งคำตอบไว้ ยกเลิกการตอบ

      อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น

      Search

      หมวดหมู่

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

      หลักสูตรล่าสุด

      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
      (00) 123 456 789
      hello@eduma.com
      Facebook
      Twitter
      Google-plus
      Pinterest

      Education WordPress Theme by ThimPress. Powered by WordPress.

      • Privacy
      • Terms
      • Sitemap
      • Purchase

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

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