  | 
				VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.   
				 | 
			 
		 
		 
	
		| 上一篇主題 :: 下一篇主題   | 
	 
	
	
		| 發表人 | 
		內容 | 
	 
	
		曹學琴
 
 
  註冊時間: 2011-07-28 文章: 1
 
  第 1 樓
  | 
		
			
				 發表於: 星期四 七月 28, 2011 2:13 pm    文章主題: 將繁體Crystal Report(*.RPT)檔轉成簡體問題 | 
				     | 
			 
			
				
  | 
			 
			
				請問一下,我參考將繁體水晶報表轉呈簡體,我是想將報表內欄位的繁體中文轉為簡體,使用VFP 9.0,程式執行時
 
Local oCR As CRAXDRT.Application
 
Local oRpt As CRAXDRT.Report
 
會跳出錯誤訊息"必須為記憶體變數或陣列"
 
RegSvr32 載入craxdrt.dll後可找到CrystalRuntime.Application,到下一行又會出錯,錯誤訊息為:OLE IDispatch exception code 0 from Crystal report Active X Designer :INvalid TLV record...
 
再下一行出現ORPT is not an object,之後也會出現一些找不到物件、變數等等的錯誤訊息,想請教是出了什麼問題,如何修改呢?
 
我是參考這個文件:http://www.craigberntson.com/docs/integratingcr.pdf
 
希望大大們能幫忙解答,非常感謝 ~
 
 	  | 代碼: | 	 		  Set Safety Off
 
Set Exact On
 
If Rpl_unicode("D:\RPT\", "D:\RPTS\")
 
Messagebox("Transfer OK!!")
 
Endif
 
Set Safety On
 
 
Function Rpl_unicode
 
Para wic, wicnew
 
 
olebig=Createobject('Hokoy.WordKit')
 
 
*!* 函式名稱 參數形式 傳回值形式
 
*!* GBtoBig5 GB Big5
 
*!* BIG5toGB Big5 GB
 
*!* GBtoUnicode GB Unicode
 
*!* Big5toUnicode Big5 Unicode
 
*!* UnicodetoGB Unicode GB
 
*!* UnicodetoBig5 Unicode Big5
 
*!* SCtoTC Unicode簡體字 Unicode繁體字
 
*!* TCtoSC Unicode繁體字 Unicode簡體字
 
 
Local LLC,MTXT,CTMP, MRPL
 
Local oCR As CRAXDRT.Application
 
Local oRpt As CRAXDRT.Report
 
 
If Para()<>2
 
=Messagebox('error',48,'error of path!!')
 
Return .F.
 
Endif
 
 
getfilenum=Adir(getfiles,wic+'*.rpt')
 
For ii=1 To getfilenum
 
Wait Wind 'process Prog: '+getfiles[ii,1] At 8,35 Nowait
 
*-------------------
 
oCR = Createobject("CrystalRuntime.Application")
 
oRpt = oCR.OpenReport(wic+ getfiles[ii,1])
 
For jj=1 To oRpt.Areas.Count
 
For kk=1 To oRpt.Areas.Item(jj).Sections.Count
 
For ll=1 To oRpt.Areas.Item(jj).Sections.Item(kk).ReportObjects.Count
 
yy = oRpt.Areas.Item(jj).Sections.Item(kk).ReportObjects.Item(ll)
 
If yy.Kind=2 && text obj
 
v_objn =0
 
v_hasobj=.F. && has obj in text?
 
*---------------save text - obj to array --------------------
 
If yy.FieldElements.Count>0
 
v_objn=yy.FieldElements.Count
 
v_hasobj=.T.
 
Dimension txtobj(v_objn,3)
 
For pp=1 To v_objn
 
txtobj(pp,1)=yy.FieldElements.Item(pp).FieldDefinition
 
txtobj(pp,3)=yy.FieldElements.Item(pp).Font.bold && 儲存BOLD狀態
 
Endfor
 
Endif
 
*---------------save text - obj to array -------------------
 
m.MTXT=Alltrim(yy.Text)
 
m.MRPL=m.MTXT && for replace
 
If Len(m.MRPL) > 0 && 一次轉換繁體->簡體UNICODE
 
v_uncode = olebig.TCtoSC(m.MRPL)
 
m.MRPL = v_uncode
 
Endif
 
If v_hasobj
 
*---------------save text - obj to text --------------------
 
For pp=1 To v_objn
 
txtobj(pp,2)=Atcc('[]',m.MRPL,pp) && ?#93;為ADD用中文算字數所以用ATCC
 
Endfor
 
m.MRPL=Strtran(m.MRPL, '[]', '')
 
oRpt.Areas.Item(jj).Sections.Item(kk).ReportObjects.Item(ll).settext(m.MRPL)
 
For pp=1 To v_objn
 
yy.FieldElements.Add(txtobj(pp,2),txtobj(pp,1))
 
yy.FieldElements.Item(pp).Font.bold = txtobj(pp,3)
 
Endfor
 
*---------------save text - obj to text -------------------
 
Else
 
oRpt.Areas.Item(jj).Sections.Item(kk).ReportObjects.Item(ll).settext(m.MRPL)
 
Endif
 
oRpt.Areas.Item(jj).Sections.Item(kk).ReportObjects.Item(ll).Font.Name="SimSun"
 
If v_hasobj && bold 字型?#93;定後才有效
 
For pp=1 To v_objn
 
yy.FieldElements.Item(pp).Font.bold = txtobj(pp,3)
 
Endfor
 
Endif
 
Endif
 
If yy.Kind=1
 
oRpt.Areas.Item(jj).Sections.Item(kk).ReportObjects.Item(ll).Font.Name="SimSun"
 
Endif
 
Endfor
 
Endfor
 
Endfor
 
oRpt.Save(Trim(wicnew)+ Alltrim(getfiles[ii,1]))
 
Endfor
 
Return .T.
 
Endfunc
 
 | 	  http://vfp.sunyear.com.tw/files/integratingcr_148.pdf
   曹學琴 在 星期四 八月 04, 2011 10:23 am 作了第 1 次修改 | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		LiuRambo
 
 
  註冊時間: 2007-11-27 文章: 481
 
  第 2 樓
  | 
		
			
				 發表於: 星期五 七月 29, 2011 10:59 am    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				CRAXDRT.Application? 這怎麼來的
 
沒有其他的程式段了嗎
 
CRAXDRT到底有沒有Createobject??? | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
  	 
	    
  	   | 
 	
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
  | 
   
  
		 |