How to using M-Power Report API M-Power Report API 力 了 M-Power Report -- Java (Library) M-Power Report API 行 Java M-Power Report M-Power Report API ( 30 ) PDF/HTML/CSV/XLS JPEG/PNG/SVG 料 料 OutputStream OutputStream email email 列 列 力 Page 1 of 13
M-Power Report API 行 M-Power Report API Java Sun J2SE Software Development Kit (SDK) 行 行 Java SDK Sun J2SE 15 Windows NT 40 SP6 Windows 2000 Acrobat Reader 5x ( PDF http://wwwchinese-tadobecom/products/acrobat/readstep2html ) Acrobat SVG Viewer 30 ( SVG http://wwwadobecom/svg/viewer/install/mainhtml ) 力 Page 2 of 13
M-Power Report API M-Power Report API jar M-Power Report API CLASSPATH M-Power Report API 路 Windows Linux 說 CLASSPATH Windows 若 M-Power Report API 路 C:\reportapi\reportapijar CLASSPATH set CLASSPATH=;C:\reportapi\reportapijar Linux 若 M-Power Report API 路 /usr/local/jar/reportapijar /etc/profile ( ) 列 CLASSPATH=/:/usr/local/jar/reportapijar export CLASSPATH Linux CLASSPATH CLASSPATH Java M-Power Report API 了 讀 例 例 了 M-Power Report API 念 例 M-Power Report 錄 ReportDesigner\APIDemo 錄 例 錄裡 Java Application 例 例 來了 M-Power Rpeort API 力 Page 3 of 13
ReportSample 立 ReportSample 類 類 main 令列 行 ReportSample 類 import javautil*; import commpowerchart*; import commpowerreport*; import commpowerreportcore*; import commpowerreportspi*; import commpowerreportutils*; public class ReportSample { public static void main(string[] args) throws Exceptoin{ String chartfilepath = getjpegchart(); Systemoutprintln("The chart has been built at :" + chartfilepath); String reportfilepath = getpdfreport(new Integer(2020)); Systemoutprintln("The report has been built at :" + reportfilepath); } public static String getpdfreport(integer orderid) throws DataSourceException, ReportEmptyException { // } public static String getjpegchart() throws DataSourceException, MPChartException{ // } } 1-1 ReportSample 力 Page 4 of 13
ReportSample 了兩 method getpdfreport( ) 來 PDF getjpegchart( ) 來 JPEG main ( ) 行 getpdfreport( ) getjpegchart( ) 來 getjpegchart( ) getpdfreport( ) 兩 力 Page 5 of 13
來 來 PDF 來 JPEG M-Power Report Designer 了 類 說 了 M-Power Report API 料 ReportSample 例 Formprint [M-Power Report 錄 ] \APIDemo\ReportSample\print 錄 Demo1_PieDemopaint [M-Power Report 錄 ] \APIDemo\ReportSample\paint 錄 ReportSample 兩 路 來 ReportSample (PDF JPEG ) [M-Power Report 錄 ]\APIDemo\ReportSample\report 錄裡 了更 易了 APIDemo 錄 理 1-1 錄 說 \lib ReportSample 行 libraries ( jar ) \paint (paint ) \print (print ) \report 1-1 APIDemo 錄 說 力 Page 6 of 13
兩 Demo Database 料 連 Demo 料 JDBC 料 便 JDBC 料 連 1-2 Demo Database JDBC 連 料 料 JDBC (Driver) orghsqldbjdbcdriver 料 URL jdbc:hsqldb:hsql://localhost:5869 sa 1-2 Demo Database JDBC 連 料 力 Page 7 of 13
來 來 getpdfreport( ) 1-2 public static String getpdfreport(integer orderid) throws DataSourceException, ReportEmptyException { String reportfilepath = "D:\\MpowerReport Eval\\APIDemo\\ReportSample\\print\\Formprint"; String destdir = "D:\\MpowerReport Eval\\APIDemo\\ReportSample\\report\\"; ReportResource resource = new ReportResource("Form"); resourcesetdsdriver("orghsqldbjdbcdriver"); resourcesetdsurl("jdbc:hsqldb:hsql://localhost:5869"); resourcesetdsuserid("sa"); resourcesetdspass(""); Map parms = CollectionssynchronizedMap(new HashMap()); parmsput("reporttitle", "Sample Form Report"); parmsput("maxorderid", orderid); resourcesetreportparms(parms); String report = ReportManagergenPDFReportToFile(reportFilePath, resource, destdir); return report; } 1-2 getpdfreport( ) 力 Page 8 of 13
getpdfreport ( ) Form,print JDBC 料 M-Power Report API ReportManager genpdfreporttofile ( ) 來 PDF 連串 ReportManager 了 PDF 1-3 genpdfreporttofile( ) 了 genpdfreporttofile ( ) 參數 String report = ReportManagergenPDFReportToFile(reportFilePath, resource, destdir); 1-3 ReportManager genpdfreporttofile ( ) genpdfreporttofile ( ) 參數 1 路 ( reportfilepath 數 ) 2 ReportResource ( resource 數 ) 3 ( destdir 數 ) 參數 路 0 APIDemo 錄 Formprint 路 參數 genpdfreporttofile ( ) M-Power Report API 路 Form 來 PDF 參數 ReportResource 料來 ReportResource 說 參數 參數不 參數 PDF APIDemo 錄 report 錄 M-Power Report API 路 錄 ( \ //) M-Power Report API 錄 力 Page 9 of 13
M-Power Report API 30 不 易 了 1-4 getjpegchart( ) getpdfreport( ) getjpegchart( ) ReportSample 類 連 Demo Database 料 Demo1_PieDemopaint 來 JPEG public static String getjpegchart() throws DataSourceException, MPChartException { String reportfilepath = "D:\\MpowerReport Eval\\APIDemo\\ReportSample\\paint\\Demo1_PieDemopaint"; String destdir = " D:\\MpowerReport Eval\\APIDemo\\ReportSample\\report\\"; ReportResource resource = new ReportResource("Demo1_PieDemo"); resourcesetdsdriver("orghsqldbjdbcdriver"); resourcesetdsurl("jdbc:hsqldb:hsql://localhost:5869"); resourcesetdsuserid("sa"); resourcesetdspass(""); String chart = ChartManagergenJPEGChartToFile(reportFilePath, resource, destdir); return chart; } 1-4 getjpegchart ( ) 力 Page 10 of 13
了 getjpegchart( ) 裡 1-2 不 1-5 String chart = ChartManagergenJPEGChartToFile(reportFilePath, resource, destdir); 1-5 genjpegcharttofile ( ) 1-5 M-Power Report API 30 API ChartManager 來 ChartManager 數 genjpegcharttofile ( ) JPEG 參數 1 路 ( reportfilepath 數 ) 2 ReportResource ( resource 數 ) 3 ( destdir 數 ) 參數 路 APIDemo 錄 paint 錄裡 Demo1_PieDemopaint 路 路 參數 genjpegcharttofile ( ) M-Power Report API 路 Demo1_PieDemo 來 JPEG 參數 ReportResource ReportResource ReportResource 類 參數 參數不 ( JPEG PNG ) 參數 getjpegchart ( ) APIDemo 錄 report 錄 M-Power Report API 路 錄 ( \ //) M-Power Report API 錄 力 Page 11 of 13
行 例 了 ReportSample 類 來 來 行 例 行 JDK (javacexe) Java ( JBuilder Eclipse NetBeans ) ReportSamplejava ReportSampleclass IDE 行 ReportSample 令 行 列 令 (! 行 Demo Database 便 料 料 ) C:\> Java ReportSample 行 1-1 行 1-1 ReportSample 行 行 錄 Formpdf Demo1_PieDemo,jpg 兩 1-2 1-2 力 Page 12 of 13
Demo1_PieDemojpg 例 1-3 1-3 JPEG 來 FormPDF 不 PDF 了 Acrobat Reader PDF PDF 力 Page 13 of 13