Pentaho Report Designer 入門教程(三),pentahodesigner

來源:互聯網
上載者:User

Pentaho Report Designer 入門教程(三),pentahodesigner

Pentaho Report Designer 入門教程(三)

       採用Pentaho Report Designer5.1版本,也是最新的版本。

一、       安裝和介紹

介紹部分內容略,首先安裝jdk,並配置java相關環境變數,下載pentaho report並解壓,直接運行即可。

二、       第一個樣本

三、在Swing程式中整合

四、在j2ee程式中整合

Ø  建立web項目

Ø  編寫ant指令碼,編譯運行項目

<?xml version="1.0"encoding="UTF-8" standalone="no"?>

<projectbasedir="."default="start_tomcat"name="Ch2WebApp">

    <propertyname="webDir"value="war"/>

    <propertyname="tomcat.home"value="D:/program/tomcat6"/>

    <pathid="classpath">

       <filesetdir="lib">

           <includename="*.jar"/>

       </fileset>

       <filesetfile="${tomcat.home}/lib/servlet-api.jar"/>

    </path>

 

    <pathid="runtime_classpath">

       <filesetdir="lib">

           <includename="*.jar"/>

       </fileset>

       <dirsetdir="classes"/>

    </path>

 

    <targetname="compile">

       <echomessage="compile"/>

       <mkdirdir="classes"/>

       <javacclasspathref="classpath"destdir="classes"srcdir="src"includeantruntime="on"fork="true"encoding="UTF-8"/>

    </target>

 

    <targetname="war"depends="compile">

       <deletefile="chapter2.war"/>

       <warbasedir="war"destfile="chapter2.war"webxml="war/WEB-INF/web.xml">

           <classesdir="classes"/>

           <zipfilesetdir="data"prefix="data"/>

           <zipfilesetdir="lib"prefix="WEB-INF/lib"/>

       </war>

      

       <deletedir="${tomcat.home}/webapps/chapter2"/>

       <deletefile="${tomcat.home}/webapps/chapter2.war"/>

       <copyfile="chapter2.war"todir="${tomcat.home}/webapps"/>

    </target>

   

    <targetname="start_tomcat"depends="war">

       <exectimeout="1000"dir="${tomcat.home}/bin"executable="${tomcat.home}/bin/shutdown.bat"/>

       <sleepseconds="2"/>

       <execdir="${tomcat.home}/bin"executable="${tomcat.home}/bin/startup.bat"/>

    </target>

   

</project>

 

Ø  測試通過servlet 訪問不同檔案格式的報表

    publicvoid init(ServletConfig config)throws ServletException {

       ClassicEngineBoot.getInstance().start();

       super.init(config);

    }

 

    protectedvoiddoGet(HttpServletRequest request,

           HttpServletResponse response)throws ServletException, IOException {

 

       try {

           ResourceManager manager =new ResourceManager();

           manager.registerDefaults();

           String reportPath = "file:"

                  + this.getServletContext().getRealPath(

                         "data/ch2_1.prpt");

           Resource res =manager.createDirectly(newURL(reportPath),

                  MasterReport.class);

           MasterReport report = (MasterReport)res.getResource();

 

           // determine the output format and renderaccordingly

           String outputFormat =request.getParameter("outputFormat");

           if ("pdf".equals(outputFormat)) {

              // render thepdf

              response.setContentType("application/pdf");

              PdfReportUtil.createPDF(report,response.getOutputStream());

           } elseif ("xls".equals(outputFormat)) {

              // render in excel

              response.setContentType("application/vnd.ms-excel");

              ExcelReportUtil.createXLS(report,response.getOutputStream());

           } elseif ("rtf".equals(outputFormat)) {

              // render inrtf

              response.setContentType("application/rtf");

              RTFReportUtil.createRTF(report,response.getOutputStream());

           }

       } catch (Exception e) {

           e.printStackTrace();

       }

       super.doGet(request, response);

    }

Ø  jsp或html檔案調用servlet

<body>

    <h1>Example Application</h1>

    <p>This is an exampleapplication demonstrating how to embed

       Pentaho Reporting into yourweb application.</p>

      

    <a href="report?outputFormat=pdf"target="black">Generate PDF Report </a><br/>

    <a href="report?outputFormat=xls"target="black">Generate Excel Report</a><br/>

    <a href="report?outputFormat=rtf"target="black">Generate RTF Report </a><br/>

</body>


Pentaho Report Designer 在 structure 中 怎編輯名稱?

找找協助文檔吧,這樣來得更快
 
有誰對pentaho report designer比較熟悉的?熟悉的加QQ136795830

你好 加 315268537
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.