pb更新oracle表格,PB自定义retrieve刷新函数、PB导入excel表、打印

2013年12月30日

//定义一个打印工作

long job

//打开打印设置

job = PrintOpen("一份数据文档")

//指定打印数据窗口

PrintDataWindow(job, dw_1)

//关闭打印工作

PrintClose(job)

2013年12月17号

//自定义刷新函数ue_refresh

string ls_big_code

ls_big_code=dw_2.object.c_name[1]

if isnull(ls_big_code) or trim(ls_big_code)='' then

ls_big_code='ALL'

end if

dw_1.retrieve('*',ls_big_code)

导入excel表全部内容

string str_savename,named,s_grxh

int excelok,li_net

long li_count,i

oleobject excelserver

excelserver=create oleobject

Excelok=excelserver.connecttonewobject (“excel.applicatiuon”)

excelok=excelserver.connecttonewobject("excel.application")

//检查返回值,以确保已成功地连接到了Excel

messagebox("信息提示",excelok)

if excelok <> 0 then

messagebox("信息提示","连接EXCEL失败,请检查计算机中是否安装了EXCEL!")

return -1

end if

li_net = GetFileOpenName("选择文件", str_savename,named,"xls","Excel文件(*.xls),*.xls")

if li_net > 0 then

if str_savename = "" then return -1

dw_1.settransobject(sqlca)

dw_1.reset()

excelserver.workbooks.open(str_savename)

excelserver.activesheet.cells.copy

li_count = dw_1.importclipboard(2) //导入数据

clipboard("")

excelserver.quit()

excelserver.disconnectobject()

destroy excelserver

messagebox('信息提示','数据导入成功!')

return 1

else

messagebox('信息提示','没有指定导入文件!')

return -1

end if

2013年12月18号

导入特定字段excel表

string ns_current_directory

string ns_app_path

ns_current_directory = space(500)

GetCurrentDirectoryA(500,ns_current_directory)

ns_app_path = ns_current_directory

string str_savename,named,s_grxh

int excelok,li_net

long ll_excel_cols,ll_excel_rows,ll_col

string ls_error_syntaxfromSQL, ls_error_create

string ls_sql, ls_syntax

oleobject excelserver

li_net = GetFileOpenName("选择文件", str_savename,named,"xls","Excel文件(*.xls),*.xls,*.xlsx")

if li_net <= 0 then

messagebox('信息提示','没有指定导入文件!')

SetCurrentDirectoryA(ns_app_path)

return -1

end if

SetCurrentDirectoryA(ns_app_path)

excelserver=create oleobject

excelok=excelserver.connecttonewobject("excel.application")

//检查返回值,以确保已成功地连接到了Excel

if excelok <> 0 then

messagebox("信息提示","连接EXCEL失败,请检查计算机中是否安装了EXCEL!")

return -1

end if

//

if str_savename = "" then return -1

if isvalid(w_process) then close(w_process)

open(w_process)

w_process.process(20)

打开文件并获得当前文件的行数和列数

excelserver.workbooks.open(str_savename)

excelserver.activesheet.cells.copy

ll_excel_rows = excelserver.activesheet.UsedRange.Rows.Count

ll_excel_cols = excelserver.activesheet.UsedRange.columns.Count

w_process.process(30)

首先动态建造一个datawindow

ls_sql = "select '' as hosp_code_s,'' as hosp_name_s,'' as item_code_s,'' as item_name_s,'' as staple_flag_s from zhangtao where prm_key<1"

ls_syntax = SQLCA.SyntaxFromSQL(ls_sql, 'Style(Type=grid)', ls_error_syntaxfromSQL)

IF Len(ls_error_syntaxfromSQL) > 0 THEN return -1

dw_temp.create(ls_syntax,ls_error_create)

w_process.process(35)

if len(ls_error_create) > 0 then return -1

//把excel的数据导入到dw_temp中

excelserver.activesheet.cells.copy

dw_temp.importclipboard()

清除内存

clipboard("")

//退出excel

excelserver.quit()

excelserver.disconnectobject()

destroy excelserver

f_kill_exe("EXCEL")

w_process.process(40)

dw_temp.deleterow(1)

string ls_hosp_code,ls_hosp_name,ls_item_code,ls_item_name,ls_staple_flag,ls_branch_no

datetime ldt_time

select sysdate

into :ldt_time

from dual;

long ll_insert_row,ll_row,ll_step,ll_count

ll_count=0

dw_1.visible = false

for ll_row = 1 to dw_temp.rowcount()

w_process.process(40+40*ll_Row/dw_temp.rowcount())

ls_hosp_code = dw_temp.object.hosp_code_s[ll_row]

ls_hosp_name = dw_temp.object.hosp_name_s[ll_row]

ls_item_code=dw_temp.object.item_code_s[ll_row]

ls_item_name=dw_temp.object.item_name_s[ll_row]

ls_staple_flag=dw_temp.object.staple_flag_s[ll_row]

ll_step = dw_1.find("hosp_code='" +ls_hosp_code+"'",1,dw_1.rowcount())

if ll_step > 0 then CONTINUE;

if isnull(ll_step) or ll_step = 0 then

ll_insert_row=dw_1.insertrow(0)

dw_1.object.hosp_code[ll_insert_row]=ls_hosp_code

dw_1.object.hosp_name[ll_insert_row]=ls_hosp_name

dw_1.object.item_code[ll_insert_row]=ls_item_code

dw_1.object.item_name[ll_insert_row]=ls_item_name

dw_1.object.staple_flag[ll_insert_row]=ls_staple_flag

dw_1.object.input_date[ll_insert_row]=ldt_time

dw_1.object.branch_no[ll_insert_row]=is_branch_no

ll_count=ll_count+1

end if

next

if isvalid(w_Process) then close(w_process)

messagebox('提示','导入完毕,成功导入数据'+string(ll_count))

dw_1.visible = true

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值