PB中怎样把数据写到已经固定格式的EXCEL表中

本文提供了一个使用特定脚本语言自动填充Excel表格的示例,包括设置表头、填充数据等步骤。通过循环读取数据并写入指定单元格,实现了高效的数据处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

int i,handle,n
handle = openchannel("Excel",'book1.xls')
if handle < 0 then
messagebox('提示','请打开EXCLE程序! 并打开BOOK1.XLS,且清空该表格!')
return
end if
setremote('r1c1' , '客户欠费分析表'     , handle)
setremote('r2c5' , '统计日期: ' + is_rq1 + ' 至 ' + is_rq2    , handle)
setremote('r3c1' , '排名' , handle)
setremote('r3c2' , '客户码' , handle)
setremote('r3c3' , '客户名称' , handle)
setremote('r3c4' , '应收总额' , handle)
setremote('r3c5' , '欠费总额' , handle)
setremote('r3c6' , '比率' , handle)
setremote('r3c7' , tab_1.tabpage_1.dw_1.object.no1_t.text , handle)
setremote('r3c8' , tab_1.tabpage_1.dw_1.object.no2_t.text , handle)
setremote('r3c9' , tab_1.tabpage_1.dw_1.object.no3_t.text , handle)
setremote('r3c10', tab_1.tabpage_1.dw_1.object.no4_t.text , handle)
setremote('r3c11', tab_1.tabpage_1.dw_1.object.no5_t.text , handle)
for i = 1 to tab_1.tabpage_1.dw_1.rowcount()
setremote("r" + string(i+3) + 'c1' , string(i) , handle)
setremote("r" + string(i+3) + 'c2' ,    tab_1.tabpage_1.dw_1.getitemstring (i , 'khbm') , handle)
setremote("r" + string(i+3) + 'c3' ,    tab_1.tabpage_1.dw_1.getitemstring (i , 'khmc') , handle)
setremote("r" + string(i+3) + 'c4' , string(tab_1.tabpage_1.dw_1.getitemdecimal(i , 'ys')) , handle)
setremote("r" + string(i+3) + 'c5' , string(tab_1.tabpage_1.dw_1.getitemdecimal(i , 'qf')) , handle)
setremote("r" + string(i+3) + 'c6' , string(tab_1.tabpage_1.dw_1.getitemdecimal(i , 'bl')) , handle)
setremote("r" + string(i+3) + 'c7' , string(tab_1.tabpage_1.dw_1.getitemdecimal(i , 'no1')) , handle)
setremote("r" + string(i+3) + 'c8' , string(tab_1.tabpage_1.dw_1.getitemdecimal(i , 'no2')), handle)
setremote("r" + string(i+3) + 'c9' , string(tab_1.tabpage_1.dw_1.getitemdecimal(i , 'no3')) , handle)
setremote("r" + string(i+3) + 'c10', string(tab_1.tabpage_1.dw_1.getitemdecimal(i , 'no4')) , handle)
setremote("r" + string(i+3) + 'c11', string(tab_1.tabpage_1.dw_1.getitemdecimal(i , 'no5')) , handle)
next
closechannel(handle)
messagebox('提示','保存完毕!')

 

转自:http://blog.youkuaiyun.com/bjash/archive/2007/07/08/1682580.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值