 |
VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
|
上一篇主題 :: 下一篇主題 |
發表人 |
內容 |
jeff25
註冊時間: 2004-10-22 文章: 76 來自: taiwan
第 1 樓
|
發表於: 星期三 四月 13, 2005 7:28 am 文章主題: 在vfp9 使用REPORT FORM XXXX OBJECT TYPE 5 |
|
|
我在 vfp9 使用 REPORT FORM xxx OBJECT TYPE 5 (xxx 是 報表檔)
希望透過 gdiplus 將報表產生為 html 檔
結果是產生了 xxx.htm 檔但卻是一個空檔(沒有任何錯誤訊息)
請教各位先進,問題可能出在哪裡? thanks _________________ jeff |
|
回頂端 |
|
 |
garfield Site Admin

註冊時間: 2003-01-30 文章: 2160
第 2 樓
|
發表於: 星期三 四月 13, 2005 2:50 pm 文章主題: |
|
|
Visual FoxPro 9.0
ReportListener HTML Foundation Class
***
LOCAL oHtml
* SET PATH TO (HOME() + "FFC") ADDITIVE
oHtml = NEWOBJECT("HtmlListener","_reportlistener.vcx")
oHtml.targetFileName = "c:\temp\myOutput.htm"
* The following lines of code set the precision of coordinates
* of most individual layout items as a number of decimal places
* (the XSLT's coordinates are in inches).
* The default number of decimal places is set in the XSLT to 5,
* but here the value is set to 6:
oHtml.xsltParameters = CREATEOBJECT("Collection")
oHtml.xsltParameters.Add(6,"numberPrecision")
* The following directory must exist *before*
* you assign the next property:
IF NOT DIRECTORY("c:\temp\images")
MD c:\temp\images
ENDIF
* Assignment of the image directory as
* a relative reference ensures
* appropriate src attributes in the
* HTML document:
oHtml.externalFileLocation = ".\images"
oHtml.copyImageFilesToExternalFileLocation = .T.
REPORT FORM ? OBJECT oHtml
MODIFY FILE (oHtml.targetFileName)
ACTI SCREEN
? oHtml.XsltProcessorUser.Stylesheet.Xml
****************************
資料來源: http://www.code-magazine.com/focus/article.aspx?quickid=0404032&page=2
有人將它翻成中文: http://www.pcom.cn/f/2004/12/8/1102398898_2.html
The following code creates an HTML file called MyReport.HTML from the MyReport report. When you specify type 5, ReportOutput.APP uses its built-in HTMLListener class to provide output.
loListener = .NULL.
do (_reportoutput) with 5, loListener
loListener.TargetFileName = 'MyReport.html'
loListener.QuietMode = .T.
report form MyReport object loListener
The following code creates an XML file, called MyReport.XML from the MyReport report, containing only the data. In this case, the XMLListener class (type 4) is used.
loListener = .NULL.
do (_reportoutput) with 4, loListener
loListener.TargetFileName = 'MyReport.xml'
loListener.QuietMode = .T.
loListener.XMLMode = 0
&& 0 = data only, 1 = layout only, 2 = both
report form MyReport object loListener
HTML output actually uses the XML listener to produce XML and then uses XSLT to produce the HTML end-result.
Both of these listener classes have additional properties you can use to further control the output. I recommend a look at the Visual FoxPro documentation for details. Also, as they are subclasses of _ReportListener, listener classes support the capabilities of the _ReportListener class, including chaining listeners and running multiple reports. Here's an example that outputs to both XML and HTML at the same time:
use _samples + 'Northwind\Orders'
loListener1 = .NULL.
do (_reportoutput) with 4, loListener1
loListener1.TargetFileName = 'MyReport.xml'
loListener1.QuietMode = .T.
loListener1.XMLMode = 0
&& 0 = data only, 1 = layout only, 2 = both
loListener2 = .NULL.
do (_reportoutput) with 5, loListener2
loListener2.TargetFileName = 'MyReport.html'
loListener2.QuietMode = .T.
loListener1.Successor = loListener2
report form MyReport object loListener1 _________________ 利用>>搜尋<<的功能會比問的還要快得到答案. |
|
回頂端 |
|
 |
jeff25
註冊時間: 2004-10-22 文章: 76 來自: taiwan
第 3 樓
|
發表於: 星期四 四月 14, 2005 11:17 am 文章主題: |
|
|
謝謝 Garfield,
上面的程式我試了,當 object type = 4 do ( 用 report form ... object type 4
或 do (_reportoutput) with 4, loListener1 產生 .xml 檔案均 ok,
看說明 report ... object type 語法比較簡單自動會使用 reportlistener, 只是無法指定輸出檔名的位置
我使用上述程式
do (_reportoutput) with 5, loListener2 與 report ... object type 5
執行時會出現 rendering page 1,2,3 ....
但最後的 html 檔均是空檔,不知為何,如果你有試出來請告知,thanks _________________ jeff |
|
回頂端 |
|
 |
jeff25
註冊時間: 2004-10-22 文章: 76 來自: taiwan
第 4 樓
|
發表於: 星期二 四月 19, 2005 4:14 pm 文章主題: |
|
|
後來 test 發現可能是中文的問題,只要在報表中全部是英文,產生的 html 檔 就 ok了
跟 report preview 一模一樣,格線圖片都 ok , 不會像 8.0 版前(_genhtml)產生的只有文字
轉存成 pdf 檔也都跟 report 印到印表機一樣
只是裡面有中文就失敗,(看其產生之html 檔 charset 是 UTF-8 ) 不知如何修正? _________________ jeff |
|
回頂端 |
|
 |
janlih
註冊時間: 2003-11-04 文章: 69
第 5 樓
|
發表於: 星期六 十二月 16, 2006 5:45 pm 文章主題: |
|
|
jeff25 寫到: | 後來 test 發現可能是中文的問題,只要在報表中全部是英文,產生的 html 檔 就 ok了
跟 report preview 一模一樣,格線圖片都 ok , 不會像 8.0 版前(_genhtml)產生的只有文字
轉存成 pdf 檔也都跟 report 印到印表機一樣
只是裡面有中文就失敗,(看其產生之html 檔 charset 是 UTF-8 ) 不知如何修正? |
我測試過也是只能英文顯示
你可以修改 _ReportListener.vcx 之 htmllistener 試試看 |
|
回頂端 |
|
 |
garfield Site Admin

註冊時間: 2003-01-30 文章: 2160
第 6 樓
|
發表於: 星期三 十二月 05, 2007 10:09 am 文章主題: |
|
|
忘了是誰提供這段說明,
你可以試看看.
VFP9 REPORT 輸出 HTML 修正中文字支援
VFP9 XSOURCE\VFPSOURCE\REPORTOUTPUT\LISTENER.VCX
找到 utilityreportlistener 下的 xmllistener 修改其 applyusertransformtooutput 這個 PROCEDURE
修正前:
lcResult = THIS.ApplyXSLT(FILETOSTR(THIS.TargetFileName),THIS.XSLTProcessorUser, THIS.XSLTParameters)
修正後:
lcResult = THIS.ApplyXSLT(STRCONV(FILETOSTR(THIS.TargetFileName),11),THIS.XSLTProcessorUser, THIS.XSLTParameters)
修正前:
STRTOFILE(lcResult,THIS.SaveTargetFileName)
修正後:
STRTOFILE(STRTRAN(lcResult,"charset=UTF-8","charset=BIG5"),M4000_TmpFile)
然後再 Build xsource\vfpsource\reportoutput\reportoutput.pjx
再將產生之 reportoutput.app 放置 c:\program files\microsoft visual foxpro 9 下
執行下列程式:
M_PREVIEW_MODE = 5
* 產生一個空物件
M_oReport = CREATEOBJECT("custom")
M_oReport.addProperty("oReportListener")
DO (_REPORTOUTPUT) WITH M_PREVIEW_MODE, "M_oReport.oReportListener"
* 定義 輸出 HTML 的路徑
M_oReport.oReportListener.TargetFileName = "D:\TEST.HTM"
* 關閉 是否將輸出HTML的路徑複製到剪貼簿 的訊息
M_oReport.oReportListener.Allowmodalmessages = .F.
M_ReportFile = "D:\TEST.LBX"
REPORT FORM (M_ReportFile) OBJECT M_oReport.oReportListener
即可在產生一個名為 TEST 的 HTML 檔了
基本上產生後的檔案 90% 以上 相似於 在報表預覽時所見之結果
應用於LABEL上亦無問題,且可正常顯示中文 _________________ 利用>>搜尋<<的功能會比問的還要快得到答案. |
|
回頂端 |
|
 |
朱育興
註冊時間: 2003-08-25 文章: 661 來自: 台中市大里區
第 7 樓
|
|
回頂端 |
|
 |
garfield Site Admin

註冊時間: 2003-01-30 文章: 2160
第 8 樓
|
發表於: 星期三 十二月 05, 2007 2:53 pm 文章主題: |
|
|
感恩喔! _________________ 利用>>搜尋<<的功能會比問的還要快得到答案. |
|
回頂端 |
|
 |
jeff25
註冊時間: 2004-10-22 文章: 76 來自: taiwan
第 9 樓
|
|
回頂端 |
|
 |
|
|
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
|
|