SQL>SPOOL C:\test.xls; SQL>select * from table; SQL>spool off;这个方法应该是比较简单的了啊?不知道还有没有比这个更简单的。期待ing......
在PB中, long numcols , numrows , c, r OLEObject xlapp , xlsub int ret// Set the # of columns and rows to process // Currently Set to copy the entire DW numcols = long(dw_1.Object.DataWindow.Column.Count) numrows = dw_1.RowCount()// Create the oleobject variable xlapp xlApp = Create OLEObject// Connect to Excel and check the return code ret = xlApp.ConnectToNewObject( "Excel.Sheet" ) if ret < 0 then MessageBox("Connect to Excel Failed !",string(ret)) return end if// Open a particular Excel file xlApp.Application.Workbooks.Open(gs_fileplace) //,false,true // Make Excel visible xlApp.Application.Visible = false// Resolve the Excel reference once // This technique shortens the script and improves performance xlsub = xlapp.Application.ActiveWorkbook.Worksheets[1]// Loop thru the Datawindow and Excel sheet // The for/next loop copies all rows for each column //----------------------//xlsub.Cells.Select //xlsub.Selection.ClearContents //xlsub.Range("F7").Selectxlsub.Range("A1").Select xlsub.Range("A1").value = dw_1.object.place.text //---------------------- For c = 1 to numcols For r = 1 to numrows xlsub.cells[r+3,c] = dw_1.object.data[r,c] Next Next//save as boolean lb_exist long i string ls_filetemp for i = 1 to 10000 ls_filetemp = "c:\p_place_" + string(i) + ".xls" lb_exist = FileExists(ls_filetemp) if lb_exist = false then // MessageBox("错误信息", "临时文件已存在,请将“c:\p_place_temp_(1-10000).xls”删除或移至其它文件夹!") // return // else xlsub.application.activeworkbook.saveas(ls_filetemp) messagebox('提示',ls_filetemp + '文件导入成功') i = 10000 end if next // xlApp.DisConnectObject() Destroy xlapp
http://www.dbonline.cn/source/oracle/20040301/BACKUP_export%20data%20to%20excel%20in%20oracle.html
不是上面这个地址上讲的 何况它只局限于本地数据库
我说的是只用一句SQL就一切OK 而实现的功能也仅仅是将
ORACLE数据库中的表字段存入到EXCEL文件中 一般做项目的话
可以作为文档保存 打印 也便于阅读 对照
但是俺能用程序解决。。
一句SQL。俺是真的不知道。。如果真能那样太好了。。
好像SQL SERVER可以。。
select * from cat;
spool off
然后将第一列分列,只有这样了.
这并不是真正的XLS文件
select * from cat;
spool off
然后将第一列分列,只有这样了.谁说不是真正的xls,你打开看看才说,OK?
=====================================
不是,这个文件的确可以直接用EXCEL打开
但不是真正的EXCEL你打开后,再保存,此时的文件类型是用TAB的分隔的文本文件
文件名也加了引号
但是如楼主所说的,是不能用spool的
也许楼主要在应用程序执行SQL语句
是在一个ORACLE论坛上 现在怎么也找不到了
SQL>select * from table;
SQL>spool off;这个方法应该是比较简单的了啊?不知道还有没有比这个更简单的。期待ing......
long numcols , numrows , c, r
OLEObject xlapp , xlsub
int ret// Set the # of columns and rows to process
// Currently Set to copy the entire DW
numcols = long(dw_1.Object.DataWindow.Column.Count)
numrows = dw_1.RowCount()// Create the oleobject variable xlapp
xlApp = Create OLEObject// Connect to Excel and check the return code
ret = xlApp.ConnectToNewObject( "Excel.Sheet" )
if ret < 0 then
MessageBox("Connect to Excel Failed !",string(ret))
return
end if// Open a particular Excel file
xlApp.Application.Workbooks.Open(gs_fileplace) //,false,true
// Make Excel visible
xlApp.Application.Visible = false// Resolve the Excel reference once
// This technique shortens the script and improves performance
xlsub = xlapp.Application.ActiveWorkbook.Worksheets[1]// Loop thru the Datawindow and Excel sheet
// The for/next loop copies all rows for each column
//----------------------//xlsub.Cells.Select
//xlsub.Selection.ClearContents
//xlsub.Range("F7").Selectxlsub.Range("A1").Select
xlsub.Range("A1").value = dw_1.object.place.text
//----------------------
For c = 1 to numcols
For r = 1 to numrows
xlsub.cells[r+3,c] = dw_1.object.data[r,c]
Next
Next//save as
boolean lb_exist
long i
string ls_filetemp
for i = 1 to 10000
ls_filetemp = "c:\p_place_" + string(i) + ".xls"
lb_exist = FileExists(ls_filetemp)
if lb_exist = false then
// MessageBox("错误信息", "临时文件已存在,请将“c:\p_place_temp_(1-10000).xls”删除或移至其它文件夹!")
// return
// else
xlsub.application.activeworkbook.saveas(ls_filetemp)
messagebox('提示',ls_filetemp + '文件导入成功')
i = 10000
end if
next
//
xlApp.DisConnectObject()
Destroy xlapp