我想把excel中某行某列的数据(数字)导入到一个静态文本框中。在网上看了半天还是没看懂,求助各位大侠!!
------解决方案--------------------
http://blog.csdn.net/jlwei888/article/details/3725362
------解决方案--------------------
oleobject lo
lo=create oleobject
if lo.connecttoobject('c:\a.xls')=0 then
sle_1.text=lo.workbooks('a.xls').sheets(1).cells(1,3).value
lo.disconnectobject()
end if
destroy lo
------解决方案--------------------
oleobject loo_oleobject
integer li_value,li_ret
string ls_path,ls_fname
li_value = GetFileOpenName("请输入文件名", &
+ ls_path, ls_fname, "XLS", &
+ "Excel文件(*.XLS),*.xls")
if li_value <> 1 then
return
end if
if not IsValid(loo_oleobject) then
loo_oleobject = Create oleobject
end if
li_ret = loo_oleobject.ConnectToObject("Excel.Application")
if li_ret <> 0 then
li_ret = loo_oleobject.ConnectToNewObject("Excel.Application")
if li_ret <> 0 then
messagebox('错误','连接Excel失败。')
loo_oleobject.DisconnectObject()
if IsValid(loo_oleobject) then
Destroy loo_oleobject
end if
end if
end if
loo_oleobject.Workbooks.Open(ls_path)
sle_1.text = String(loo_oleobject.ActiveSheet.Cells(行号,列号).value)
loo_oleobject.Quit()
loo_oleobject.DisConnectObject()
if IsValid(loo_oleobject) then
Destroy loo_oleobject
end if
------解决方案--------------------
用formula one 简单些
------解决方案--------------------
循环读取,然后写入