前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于PowerBuilder的搜索

将数据窗口对象中的数据导出到excel-----PowerBuilder_一生一念间_百度空间 相册 广场游戏 登录注册 关注此空间 一生一念间 2008-02-08 12:42 将数据窗口对象中的数据导出到excel-----PowerBuilder //参数:datawindow adw,返回:integerconstant integer ppLayoutBlank = 12OLEObject ole_objectole_object = CREATE OLEObjectinteger li_retli_ret = ole_object.ConnectToObject("","Excel.Application")IF li_ret <> 0 THEN//如果Excel还没有打开,则新建。li_ret = ole_object.ConnectToNewObject("Excel.Application")if li_ret <> 0 thenMessageBox('OLE错误','OLE无法连接!错误号:' + string(li_ret))return 0end ifole_object.Visible = TrueEND IFpointer oldpointeroldpointer = SetPointer(HourGlass!)ole_object.Workbooks.Addlong ll_colnum,ll_rownumstring ls_valuestring ls_objects,ls_obj,ls_objs[],ls_objtag[]long ll_pos,ll_len,ll_num = 0ls_objects = trim(adw.Describe('datawindow.Objects'))do while (pos(ls_objects,"~t") > 0)ll_pos = pos(ls_objects,"~t")ll_len = ll_pos - 1ls_obj = left(ls_objects,ll_len)if (adw.Describe(ls_obj + '.type') = 'column' or &adw.Describe(ls_obj + '.type') = 'compute') and &(adw.Describe(ls_obj + '.band') = 'detail') and (ls_obj <> "lsh") then ll_num += 1 ls_objs[ll_num] = ls_obj ls_objtag[ll_num] = adw.Describe(ls_obj +'_t' + '.text')end if ls_objects = right(ls_objects,len(ls_objects) - ll_pos)loop//得到数据窗口数据的列数与行数(行数应该是数据行数 + 1)ll_colnum = ll_numll_rownum = adw.rowcount() + 1string ls_colnameinteger i,j,kfor i = 1 to ll_colnum//得到标题头的名字ls_value = ls_objtag[i]ole_object.cells(1,i).value = ls_valuenextstring column_namefor i = 2 to ll_rownumfor j = 1 to ll_colnum column_name = ls_objs[j] if adw.Describe(column_name + '.type') = 'column' then ls_value = adw.Describe("Evaluate('LookupDisplay("+column_name+")',"+string(i - 1)+")") end if if adw.Describe(column_name + '.type') = 'compute' then ls_value = adw.Describe("Evaluate('" + adw.Describe(column_name + '.expression') + "',"+string(i - 1)+")") end if ole_object.cells(i,j).NumberFormatLocal = 'G/通用格式'//三种日期格式 if column_name = 'llrq' then ole_object.cells(i,j).NumberFormatLocal = 'yyyy-mm-dd' end if if column_name = 'jcsj' then ole_object.cells(i,j).NumberFormatLocal = 'yyyy年mm月' end if if column_name = 'pgsd' then ole_object.cells(i,j).NumberFormatLocal = 'yyyy年mm月dd日' end if//强制文本显示:excel默认为数字,在数据前加',即可强制转换为文本显示。if column_name = 'szcs' then ls_value = "'" + ls_value end if if column_name = 'dh' then ls_value = "'" + ls_value end if ole_object.cells(i,j).value = ls_valuenextnextSetPointer(oldpointer)ole_object.disconnectobject()DESTROY ole_objectmessagebox('提示','数据已完成导出!')return 1 #PowerBuilder 分享到: 举报 浏览(127) 评论(1) 转载 你可能也喜欢 【冬の恋歌*part 1】蓝紫诱惑 【bjd私养】红茶午后(DL怜昔&一夕) 玄珠带蛱蝶 恋物:盒子先生 【外景】【苏凤纭】夕阳的余晖(MK吉恩) 七彩指甲,你爱么 PowerBuilder数据窗口技巧十则 评论 帮助中心 | 空间客服 | 投诉中心 | 空间协议&copy;2014 Baidu