您的位置:首页 > 其它

将DW数据窗口导出为EXCEL文件的方法(整理)

2008-04-27 05:21 477 查看
本文为摘自CSDN论坛帖子收集整理后汇总版本:

---2004年9月3日整理

---原贴见:
http://community.csdn.net/Expert/topic/3328/3328715.xml?temp=8.050799E-04
鉴于现在很多朋友询问pb数据导出到EXCEL中的问题,导出去后格式和数据
类型不对了,自己写了几个用户对象,
希望能抛砖引玉,加强技术交流,得到大家的支持。

1.nvo_EXCEL只要是两个接口函数
导出数据存储的数据,可以定义EXCEL的标题
publicfunctionintegeruf_toEXCEL(datastoreads_data,readonlystringas_title)

导出数据窗口的数据,可以定义EXCEL的标题
publicfunctionintegeruf_toEXCEL(datawindowaDW_data,readonlystringas_title)

2.下面是两个用户对象的sru文件,自己导入到工程中
$PBExportHeader$uo_ds_base.sru
$PBExportComments$数据存储基类
forward
globaltypeuo_ds_basefromdatastore
endtype
endforward

globaltypeuo_ds_basefromdatastore
stringdataobject="d_expression"
endtype
globaluo_ds_baseuo_ds_base

forwardprototypes
publicfunctionanyuf_getitemvalue(longal_row,stringas_colname)
publicfunctionstringuf_about()
publicfunctionstringuf_globalreplace(stringas_source,stringas_old,stringas_new)
endprototypes

publicfunctionanyuf_getitemvalue(longal_row,stringas_colname);
//*************************************************//
//function:得到任意的列的值
//parm :
// 1.al_row :指定行
// 2.as_colname :指定列的列名
//return :-1isfailorsuccessisvaluetoyou
//author :hzh
//date :2002.11.05
//************************************************//

Strings_tempcoltype
anya_ret
s_tempcoltype=Lower(THIS.Describe(as_colname+".coltype"))

//forstringtype
IFLeft(s_tempcoltype,4)="char"ORLeft(s_tempcoltype,4)="varc"then
a_ret=THIS.GetItemString(al_row,as_colname)
ENDIF

//fordecimaltype
IFLeft(s_tempcoltype,7)="decimal"then
a_ret=THIS.GetItemDecimal(al_row,as_colname)
ENDIF

//fordatetype
IFs_tempcoltype="date"THEN
a_ret=THIS.GetItemDate(al_row,as_colname)
ENDIF

//fordatetimetype
IFs_tempcoltype="datetime"THEN
a_ret=THIS.GetItemDateTime(al_row,as_colname)
ENDIF

//fornumbertype
IFs_tempcoltype="number"THEN
a_ret=THIS.GetItemNumber(al_row,as_colname)
ENDIF

//fortimetype
IFs_tempcoltype="time"THEN
a_ret=THIS.GetItemTime(al_row,as_colname)
ENDIF

//fortimestamptype
IFs_tempcoltype="timestamp"THEN
a_ret=THIS.GetItemTime(al_row,as_colname)
ENDIF

//forintorlong
IFs_tempcoltype="int"ORs_tempcoltype="long"THEN
a_ret=THIS.GetItemnumber(al_row,as_colname)
ENDIF

IFIsNull(a_ret)THEN
RETURN-1
ENDIF

RETURNa_ret

endfunction

publicfunctionstringuf_about();
strings_func=""

s_func="1.求得表达式的值(uf_evaluate)"+&
"2.根据SQL,创建数据存储(uf_setsqlselect)~r~n"+&
"3.得到任意列的值(uf_getitemvalue)~r~n"

//s_func+=SUPER::uf_about()1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: