记得以前学习FOXPRO的时候,有把.DBF文件生成文本文件和EXCEL文件的语句,如:
use d.dbf
copy to e:\d.xls xls
copy to e:\d.txt sdf但是,ORACLE里面好象没有直接的语句生成EXCEL或者TXT文件的吗?
谢谢.
use d.dbf
copy to e:\d.xls xls
copy to e:\d.txt sdf但是,ORACLE里面好象没有直接的语句生成EXCEL或者TXT文件的吗?
谢谢.
set termout off
set echo off
set feedback off
set heading off
set line 1000
select * from emp;
spool off
set pagesize 0; ---设置每一页的行数
set feedback off; ---设置显示“已选择XX行”
set linesize 1000; ---设置列的大小
set echo off; ---设置运行命令是是否显示语句spool c:\a.txt ---导出的数据所在的目录(会自动生成)
------
这个地方是sql语句 可以调用存储过程 ,查询,删除等。
例如:Exec proc_name;
delete from temp;select * from emp; 不过导出的数据都是查询表里的数据------
spool off
set ... 都是PL/SQL 显示页面上的一些规范 。
还是说实际的需求吧:
我在电信公司上班,由于每天领导需要看前一天的业务发展情况,比如某个分公司下面的营销中心昨天的移动业务发展得怎么样了?领导要求我们一上班就要提供,服务器上原始的明细数据是在凌晨1点钟左右就生成了,而为了每天能够一上班就可以有数据提供.现在的做法是:我不得不提前一个钟头上班,从服务器上下载原始的明细数据到本地硬盘(SAVE AS 为TXT文件),然后导入为FOXPRO文件,然后在利用FOXPRO所编写的小程序生成统计的EXCEL文件.
今天,我们市公司开放了服务器的权限,我们可以直接上去取数和操作,我的意思是:可以编写一个过程,在某个时候(比如定时为早上7点正),通过在服务器上操作取得市公司生成的原始的明细数据,利用ORACLE操作统计,生成一个EXCEL文件,然后保存到本地硬盘上,这样,我就不用每天都提前上班了.
------因为以前都是使用FOXPRO,对ORACLE不熟悉,因此有此一问,看看各位大虾们有什么好的建议和操作指导,谢谢。
我也不懂哦。
------今天,刚在当当网买了一本书ORACLE 基础教程,是人民邮电出版社出版的,也不知道好不好用。没有办法,压力太大了,只能边学边用了。
A good way to read/write/control Miscrosoft office apps is through the OLE system.
You can create a PLL that can be attached to any form that you need to work with Excel.The PLL should consist of a pl/sql package:The package spec:PACKAGE excel IS
-- global variables (constants)
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type; procedure open_excel;
procedure close_excel;
procedure read_num_cell( p_row number, p_col number, p_value in out number );
procedure read_chr_cell( p_row number, p_col number, p_value in out varchar2 );
procedure open_workbook;
procedure close_workbook;
procedure open_excel_doc( p_pateka varchar2 );
procedure close_excel_doc;
procedure activate_sheet( p_redosled integer );
end;PACKAGE BODY excel IS procedure open_excel is
begin
application := ole2.create_obj('Excel.Application');
end;
procedure close_excel is
begin
if worksheet is not null then
ole2.release_obj(worksheet);
end if;
if worksheets is not null then
ole2.release_obj(worksheets);
end if;
if workbook is not null then
ole2.release_obj(workbook);
end if;
if workbooks is not null then
ole2.release_obj(workbooks);
end if;
if application is not null then
ole2.release_obj(application);
end if;
end;
procedure read_num_cell( p_row number, p_col number, p_value in out number ) is
args ole2.list_type;
cell ole2.obj_type;
begin
args := ole2.create_arglist;
ole2.add_arg(args, p_row );
ole2.add_arg(args, p_cel );
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
p_value := ole2.get_num_property(cell,'Value');
ole2.release_obj(cell);
end;
procedure read_chr_cell( p_row number, p_col number, p_value in out varchar2 ) is
args ole2.list_type;
cell ole2.obj_type;
begin
args := ole2.create_arglist;
ole2.add_arg(args, p_row );
ole2.add_arg(args, p_col );
cell := ole2.get_obj_property(worksheet,'Cells',args);
ole2.destroy_arglist(args);
p_value := ole2.get_char_property(cell,'Value');
ole2.release_obj(cell);
end; procedure open_workbook is
begin
workbooks := ole2.get_obj_property(application,'Workbooks');
end; procedure close_workbook is
begin
ole2.invoke(workbooks,'Close');
end;
procedure open_excel_doc( p_pateka varchar2 ) is
args ole2.list_type;
begin
args := ole2.create_arglist;
ole2.add_arg(args, p_pateka );
workbook := ole2.invoke_obj(workbooks, 'Open', args);
ole2.destroy_arglist(args);
worksheets := ole2.get_obj_property (workbook,'Worksheets');
end;
procedure close_excel_doc is
begin
ole2.invoke(workbook, 'Close');
end;
procedure activate_sheet( p_redosled integer ) is
args ole2.list_type;
begin
args := ole2.create_arglist;
ole2.add_arg(args, p_redosled );
worksheet := ole2.get_obj_property(worksheets,'Item', args);
ole2.destroy_arglist(args);
ole2.invoke( worksheet, 'Activate');
end;
end;
THEN attach the PLL to the form and IN THE MAIN PROCEDURE in the form:declare
p_value number := 4;
begin
EXCEL.open_excel;
EXCEL.open_workbook;
EXCEL.open_excel_doc('c:\a.xls');
EXCEL.activate_sheet(1); -- 1 is the first worksheet from left
EXCEL.READ_NUM_CELL(1, 1, p_value);
-- do what is needed with the p_value
EXCEL.close_excel_doc;
EXCEL.close_workbook;
EXCEL.close_excel;
end;
还有青蛙的使用,我GOOOOGLE了好久都GO不出来。
谢谢各位。