紧急请教!excel相关问题!!请教十豆三等诸位高手指教!!谢谢
bao1=CREATEOBJECT( "Excel.application ")
bao1.Workbooks.Open( "d:\rs\bao.xls ")
local hang,ll
hang=36
for i = 1 to _dw
for j=1 to 47
ll=j+2
bao1.cells(hang,ll).value =tongji(i,j)
endfor
&&再36之前插入新行,且每次都向前减一行
bao1.ActiveSheet.Rows(hang).Insert
endfor
local resultname,lcFileName,lcFileName0
lcFileName0= ' '
lcFileName= ' '
resultname= ' '
resultname=PUTFILE( ' ', 'Excel表名 ', 'XLS ')&&用户自己输入
bao1.ActiveWorkbook.SaveAs(resultname)
Wait Wind '正在处理,请等待...... ' Nowait
IF !EMPTY(resultname)
return
=messagebox( "文件名为空!!不进行操作!! ",36, "提示!! ")
ELSE
bao1.ActiveWorkbook.SaveAs(resultname)
ENDIF
*关闭工作簿
*bao1.Workbooks.close
*退出Excel
bao1.quit
*bao1.ActiveWorkbook.close(.f.)
if type( 'bao1 ')== 'O ' &&大写字母O
RELEASE bao1
ENDIF
RELEASE bao1
=messagebox( "导出成功!! ",36, "提示!! ")
clear
以上代码的问题:
1.每次执行后都会出现 "不能将对象赋给数组 "的错误!
但是,必须在执行之前,在命令窗口输入:clear all
才能继续执行!
2.每次执行后,excel进程总也不能自动关闭!
请教十豆三等诸位高手指教!!谢谢
[解决办法]
哪一句有问题
[解决办法]
*关闭工作簿
*bao1.Workbooks.close
*退出Excel
bao1.quit
*bao1.ActiveWorkbook.close(.f.)
if type( 'bao1 ')== 'O ' &&大写字母O
RELEASE bao1
ENDIF
改为:
bao1.Workbooks.close
bao1.quit
RELEASE bao1
[解决办法]
bao1=CREATEOBJECT( "Excel.application ")
bao1.Workbooks.Open( "d:\test\test_a.xls ")
local hang,ll
hang=36
for i = 1 to _dw
for j=1 to 47
ll=j+2
bao1.cells(hang,ll).value =tongji(i,j)
endfor
&&再36之前插入新行,且每次都向前减一行
bao1.ActiveSheet.Rows(hang).Insert
endfor
local resultname,lcFileName,lcFileName0
lcFileName0= ' '
lcFileName= ' '
resultname= ' '
resultname=PUTFILE( ' ', 'Excel表名 ', 'XLS ')&&用户自己输入
IF EMPTY(resultname)
bao1.Workbooks.close
bao1.quit
RELEASE bao1
=messagebox( "文件名为空!!不进行操作!! ",48, "提示!! ")
return
ELSE
Wait Wind '正在处理,请等待...... ' Nowait
bao1.ActiveWorkbook.SaveAs(resultname)
=messagebox( "导出成功!! ",64, "提示!! ")
ENDIF
bao1.ActiveWorkbook.saved=.t. &&放弃保存
*bao1.ActiveWorkbook.save &&保存
bao1.Workbooks.close
bao1.quit
RELEASE bao1