|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
也就是说在php本地调用pdoprepare中的mysql_real_escape_string来操作query,使用的是本地单字节字符集,即编码为xbfx5cx27,并带入到mysql中查询,由于使用setnames设置了连接字符集.word|程序|数据|源代码PowerBulider数据窗口转MicroSoftExecl、Word程序源代码
1、f_cncharnum函数f_cncharnum.srf
$PBExportHeader$f_cncharnum.srf
$PBExportComments$失掉字符串中汉字大概双字节的个数
globaltypef_cncharnumfromfunction_object
endtype
forwardprototypes
globalfunctionintegerf_cncharnum(stringaString)
endprototypes
globalfunctionintegerf_cncharnum(stringaString);
//函数名:f_cncharnum
//用处:前往一个字符串中汉字的个数
//输出:aString-string,给定的字符串
//前往值:li_num-Integer,给定的字符串中汉字的个数
//注重:1.此办法基于汉字的国标汉字库区位编码的无效性,不切合此编码的体系此函数有效!
//2.若汉字串含有非汉字字符,如图形标记或ASCII码,则这些非汉字字符将坚持稳定.
//比方:li_ret=f_cncharnum("摆渡人ferryman")li_ret=3
stringls_ch//一时单位
stringls_SecondSecTable//寄存一切国标二级汉字读音
integerli_num=0//前往值
integeri,j
Fori=1toLen(aString)
ls_ch=Mid(aString,i,1)
IfAsc(ls_ch)>=128then//是汉字
li_num++
i=i+1
Endif
Next
Returnli_num
endfunction
2、PBToExcel函数f_outputtoexcel_new.srf
$PBExportHeader$f_outputtoexcel_new.srf
globaltypef_outputtoexcel_newfromfunction_object
endtype
forwardprototypes
globalfunctionintegerf_outputtoexcel_new(datawindowadw)
endprototypes
globalfunctionintegerf_outputtoexcel_new(datawindowadw);
//函数名:f_outputtoexcel_new
//输出:adw-datawindow,指定的数据窗口
//前往值:Integer
constantintegerppLayoutBlank=12
OLEObjectole_object
ole_object=CREATEOLEObject
integerli_ret
li_ret=ole_object.ConnectToObject("","Excel.Application")
IFli_ret0THEN
//假如Excel还没有翻开,则新建。
li_ret=ole_object.ConnectToNewObject("Excel.Application")
ifli_ret0then
MessageBox(OLE毛病,OLE没法毗连!毛病号:+string(li_ret))
return0
endif
ole_object.Visible=True
ENDIF
pointeroldpointer
oldpointer=SetPointer(HourGlass!)
ole_object.Workbooks.Add
longll_colnum,ll_rownum
stringls_value
stringls_objects,ls_obj,ls_objs[],ls_objtag[]
longll_pos,ll_len,ll_num=0
ls_objects=trim(adw.Describe(datawindow.Objects))
dowhile(pos(ls_objects,"~t")>0)
ll_pos=pos(ls_objects,"~t")
ll_len=ll_pos-1
ls_obj=left(ls_objects,ll_len)
if(adw.Describe(ls_obj+.type)=columnor&
adw.Describe(ls_obj+.type)=compute)and&
(adw.Describe(ls_obj+.band)=detail)and(ls_obj"asd")then
ll_num+=1
ls_objs[ll_num]=ls_obj
ls_objtag[ll_num]=adw.Describe(ls_obj+.tag)
endif
ls_objects=right(ls_objects,len(ls_objects)-ll_pos)
loop
//失掉数据窗口数据的列数与行数(行数应当是数据行数+1)
ll_colnum=ll_num
ll_rownum=adw.rowcount()+1
stringls_colname
integeri,j,k
fori=1toll_colnum
//失掉题目头的名字
ls_value=ls_objtag[i]
ole_object.cells(1,i).value=ls_value
next
stringcolumn_name
fori=2toll_rownum
forj=1toll_colnum
column_name=ls_objs[j]
ifadw.Describe(column_name+.type)=columnthen
ls_value=adw.Describe("Evaluate(LookupDisplay("+column_name+"),"+string(i-1)+")")
endif
ifadw.Describe(column_name+.type)=computethen
ls_value=adw.Describe("Evaluate("+adw.Describe(column_name+.expression)+","+string(i-1)+")")
endif
ole_object.cells(i,j).value=ls_value
next
next
SetPointer(oldpointer)
ole_object.disconnectobject()
DESTROYole_object
return1
endfunction
3、PBToWord函数f_outputtoword_new.srf
$PBExportHeader$f_outputtoword_new.srf
globaltypef_outputtoword_newfromfunction_object
endtype
forwardprototypes
globalfunctionintegerf_outputtoword_new(datawindowadw)
endprototypes
globalfunctionintegerf_outputtoword_new(datawindowadw);
//函数名:f_outputtoword_new
//输出:adw-datawindow,指定的数据窗口
//前往值:Integer
constantintegerppLayoutBlank=12
OLEObjectole_object
ole_object=CREATEOLEObject
integerli_ret
li_ret=ole_object.ConnectToObject("","word.application")
IFli_ret0THEN
//假如Word还没有翻开,则新建。
li_ret=ole_object.ConnectToNewObject("word.application")
ifli_ret0then
MessageBox(OLE毛病,OLE没法毗连!毛病号:+string(li_ret))
return0
endif
ole_object.Visible=True
ENDIF
longll_colnum,ll_rownum
constantlongwdWord9TableBehavior=1
constantlongwdAutoFitFixed=0
constantlongwdCell=12
stringls_value
pointeroldpointer
oldpointer=SetPointer(HourGlass!)
stringls_objects,ls_obj,ls_objs[],ls_objtag[]
longll_pos,ll_len,ll_num=0
ls_objects=trim(adw.Describe(datawindow.Objects))
dowhile(pos(ls_objects,"~t")>0)
ll_pos=pos(ls_objects,"~t")
ll_len=ll_pos-1
ls_obj=left(ls_objects,ll_len)
if(adw.Describe(ls_obj+.type)=columnor&
adw.Describe(ls_obj+.type)=compute)and&
(adw.Describe(ls_obj+.band)=detail)and(ls_obj"asd")then
ll_num+=1
ls_objs[ll_num]=ls_obj
ls_objtag[ll_num]=adw.Describe(ls_obj+.tag)
endif
ls_objects=right(ls_objects,len(ls_objects)-ll_pos)
loop
//失掉数据窗口数据的列数与行数(行数应当是数据行数+1)
ll_colnum=ll_num
ll_rownum=adw.rowcount()+1
ole_object.Documents.Add()
ole_object.ActiveDocument.Tables.Add(ole_object.Selection.Range,ll_rownum,ll_colnum)
stringls_colname
integeri,j,k
fori=1toll_colnum
//失掉题目头的名字
ls_value=ls_objtag[i]
ole_object.Selection.TypeText(ls_value)
fork=1tof_cncharnum(ls_value)
ole_object.Selection.TypeBackspace()
next
ole_object.Selection.MoveRight(wdCell)
next
adw.setredraw(false)
ole_object.Selection.MoveLeft(wdCell)
stringcolumn_name
fori=2toll_rownum
forj=1toll_colnum
column_name=ls_objs[j]
ifadw.Describe(column_name+.type)=columnthen
ls_value=adw.Describe("Evaluate(LookupDisplay("+column_name+"),"+string(i-1)+")")
endif
ifadw.Describe(column_name+.type)=computethen
ls_value=adw.Describe("Evaluate("+adw.Describe(column_name+.expression)+","+string(i-1)+")")
endif
ole_object.Selection.MoveRight(wdCell)
ole_object.Selection.TypeText(ls_value)
fork=1tof_cncharnum(ls_value)
ole_object.Selection.TypeBackspace()
next
next
next
adw.setredraw(true)
constantlongwdFormatDocument=0
SetPointer(oldpointer)
//保留新建的文档
ifmessagebox("保留","文档已乐成完成,是不是保留?",Question!,YesNo!)=1then
stringdocname,named
integervalue
value=GetFileSaveName("选择文件",docname,named,"DOC","DocFiles(*.DOC),*.DOC")
IFvalue=1THEN
ole_object.ActiveDocument.SaveAs(docname,0,False,"",True,"",False,False,False,False,False)
endif
endif
//断开OLE毗连
Ole_Object.DisConnectObject()
DestroyOle_Object
return1
endfunction
MySQL是一个开放源码的小型关联式数据库管理系统,开发者为瑞典MySQLAB公司。目前MySQL被广泛地应用在Internet上的中小型网站中。 |
|