oracle查询结果写入到EXCEL中(字段和结果数据都必须写入)?
本帖最后由 lusheng0028 于 2011-8-1 13:09 编辑oracle查询结果写入到EXCEL中(字段和结果数据都必须写入)?
#include <Array.au3>
#include <Excel.au3>
#include <SQLite.au3>
ProgressOn("进度条", "程序运行中", "0 %")
;Local $role
;Local $aResult, $iRows, $iColumns, $iRval
$Connection ="DRIVER={MICROSOFT ODBC FOR ORACLE};Server=orcl;User Id=picc;Password=181818"
_FileWriteLog("e:\my.log",$Connection)
$adoCon=ObjCreate("ADODB.Connection");建立ADO对象
$adoCon.open($Connection)
_FileWriteLog("e:\my.log",$Connection)
$adoRs=ObjCreate("ADODB.Recordset");建立数据集对象
$adoRs.ActiveConnection=$adoCon ;绑定连接
$adoRs.open("select * frombak_menusubrights_110622")
$oExcel=objcreate("excel.application")
$oExcel.visible=False
$oExcel.workbooks.add
ProgressSet(10 , "请等待", "程序正在运行")
With $oExcel.activesheet
.range("A1").copyfromrecordset($adoRs)
EndWith
$adoRs.close
$adoCon.close
_ExcelBookSaveAs($oExcel, "e:\temp3.xls", "xls", 0, 1)
_ExcelBookClose($oExcel, 1, 0)
;Sleep(100)
ProgressSet(100 , "完成", "Complete")
Sleep(600)
ProgressOff() 至今没看到autoit处理oracle的例子,遗憾 楼主先写下查询的代码看下 回复 2# netegg
用COM ADODB对象应该可以,没有Oracle可联,没法试
象下面这样子,应该可以的:
$OraObj = ObjCreate("ADODB.Connection")
With $OraObj
.ConnectionString =("Provider='OraOLEDB.Oracle';Data Source=" & $SID & ";User Id='" & $UID & "';Password='"& $Pin & "';")
.Open
EndWith
$OraObjSet = ObjCreate("ADODB.RecordSet")
然后就可以用这个对象句柄$OraObjSet调用各种方法来操作SQL记录了
象
$OraObjSet..MoveFirst
$OraObjSet..MoveNext
#include <Array.au3>
#include <Excel.au3>
#include <SQLite.au3>
ProgressOn("进度条", "程序运行中", "0 %")
;Local $role
;Local $aResult, $iRows, $iColumns, $iRval
$Connection ="DRIVER={MICROSOFT ODBC FOR ORACLE};Server=orcl;User Id=picc;Password=181818"
_FileWriteLog("e:\my.log",$Connection)
$adoCon=ObjCreate("ADODB.Connection");建立ADO对象
$adoCon.open($Connection)
_FileWriteLog("e:\my.log",$Connection)
$adoRs=ObjCreate("ADODB.Recordset");建立数据集对象
$adoRs.ActiveConnection=$adoCon ;绑定连接
$adoRs.open("select * frombak_menusubrights_110622")
$oExcel=objcreate("excel.application")
$oExcel.visible=False
$oExcel.workbooks.add
ProgressSet(10 , "请等待", "程序正在运行")
With $oExcel.activesheet
.range("A1").copyfromrecordset($adoRs)
EndWith
$adoRs.close
$adoCon.close
_ExcelBookSaveAs($oExcel, "e:\temp3.xls", "xls", 0, 1)
_ExcelBookClose($oExcel, 1, 0)
;Sleep(100)
ProgressSet(100 , "完成", "Complete")
Sleep(600)
ProgressOff() 回复 3# kevinch
写了 http://www.autoitx.com/thread-7797-1-4.html
论坛里找到一个,没仔细看 SELECT SYSCOLUMNS.NAME FROM SYSCOLUMNS WHERE SYSCOLUMNS.ID=OBJECT_ID('bak_menusubrights_110622')先用这句导出表头试下,然后再导出内容 好像论坛上有例子,不过要修改一下 MYSQL的 没有问题
应该类似 UDF可用,我这里测试过ORACLE10G的哈 回复 11# menfan1
udf 的哪一个函数啊
页:
[1]