on 01-26-2016 2:41 PM
hello sir/madam
I try the following code,my purpose was I tried to export a Rich Text Datawindows to a MS-Word file,when the file have exported,there's nothing on it,I don't know what I have done wrong
//dw_exp is datawindow which is rich text datawindow
//rte_exp is rich text edit which I tried to export to a ms-word file
//dw_sub is the source that I trie to replace some text in dw_exp with.
//my
value = getfilesavename( "SAVEAS" ,path,name, "doc" , "Word files( *.doc),*.doc" ) |
if value=1 then
dw_exp.reset()
dw_exp.retrieve(ld_caseid)//I can't see the records appeared when it executed here.but actually there's a record in the table,just can't figure it out
rte_exp.Clear()
string ls_richtext
string ls_prodname,ls_gjfzlx,ls_batch,ls_jx
decimal ld_nxl,ld_ncl
long ll_thenumber
ls_richtext=dw_exp.CopyRTF()
rte_exp.PasteRTF( ls_richtext)
rte_exp.SetRedraw(False)
//the follwoing code I just tried to replace some text on the RTE control
ll_type1count=0
ll_type2count=2
for li_rowsub=1 to dw_sub.rowcount()
ls_type=dw_sub.getitemstring(li_rowsub,"thetype")
ls_prodname=dw_sub.getitemstring(li_rowsub,"prod_name")
ls_gjfzlx=dw_sub.getitemstring(li_rowsub,"gjzlm")
ls_batch=dw_sub.getitemstring(li_rowsub,"ph")
ls_jx=dw_sub.getitemstring(li_rowsub,"jx")
ld_nxl=dw_sub.getitemdecimal(li_rowsub,"nxsl")
ld_ncl=dw_sub.getitemdecimal(li_rowsub,"ncl")
if isnull(ls_type) then
ll_type1count++
ll_thenumber=ll_type1count
else
ll_type2count++
ll_thenumber=ll_type2count
end if
Integer li_Loc
li_Loc =rte_exp.Find("name"+string(ll_thenumber), True, &
true, &
true, True )
if li_Loc > 0 then
rte_exp.ReplaceText(ls_prodname )
end if
li_Loc =rte_exp.Find("prodname"+string(ll_thenumber), True, &
true, &
true, True )
if li_Loc > 0 then
rte_exp.ReplaceText( ls_gjfzlx )
end if
li_Loc =rte_exp.Find("batch"+string(ll_thenumber), True, &
true, &
true, True )
if li_Loc > 0 then
rte_exp.ReplaceText( ls_batch )
end if
li_Loc =rte_exp.Find("jx"+string(ll_thenumber), True, &
true, &
true, True )
if li_Loc > 0 then
rte_exp.ReplaceText( ls_jx )
end if
li_Loc =rte_exp.Find("sellanu"+string(ll_thenumber), True, &
true, &
true, True )
if li_Loc > 0 then
rte_exp.ReplaceText(string(ld_nxl) )
end if
li_Loc =rte_exp.Find("produceanu"+string(ll_thenumber), True, &
true, &
true, True )
if li_Loc > 0 then
rte_exp.ReplaceText(string(ld_ncl) )
end if
next
rte_exp.SaveDocument(path,FileTypeDoc! )
end if
thanks
regards
Ken
please help,my problem hasn't resolved
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've used RTF datawindows and RTF controls for awhile, and they're a mess. If you can avoid them at all I would. I have a to-do to move everything to OLE and Word, and skip the whole RTF datawindow altogether. (More code, less messing around.)
When using a datawindow, always specify all parameters to the CopyRTF function.
is_copytext = dw_2.CopyRTF( TRUE, DETAIL! )
When using a datastore, I have even more problems. Here's what I have to do to successfully get the data out.
ls_ret = lnds_form.Modify( "Datawindow.RichText.InputFieldNamesVisible=No" )
ls_letter = lnds_form.CopyRTF( FALSE, DETAIL! )
Good luck buddy.
Hi Ken;
FWIW: Make sure that you check all your method call return codes.
For example:
1) Retrieve ( ) .... Check # Rows
2) CopyRTF () ... Check the Length of the text returned
etc
Regards ... Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chris
I still have issue,although I'm very familar with Grid & free style Datawindow and I have used PB for 5 years,however, I'm not familar with rich text datawindow and rich text edit control at all.I have trouble that I have copy the document form rich text datawindow,but the data which produce by columns didn't on the RTE control,there is no data except the documnet content on the ms-word file.and I have googled this and watch the help file for almost a day,I didn't found the answer,I can't figure out what I have done wrong.please help
my code is following ,thanks!
dw_exp.reset()
dw_exp.retrieve(ld_caseid)
rte_exp.Clear()
string ls_prodadd
datetime ld_begtime,ld_endtime
string ls_taken,ls_yyyy
ls_richtext=dw_exp.CopyRTF(false)
ll_thecount=rte_exp.PasteRTF( ls_richtext,Detail!)
if ll_thecount<0 then
messagebox("warnning","application terminated,because there are exception on pasting")
return
end if
rte_exp.SetRedraw(TRUE) | |
rte_exp.SaveDocument(path,FileTypeDoc! ) | |
messagebox("hello","export finish!") Regards Ken | |
User | Count |
---|---|
84 | |
9 | |
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.