利用developer 2000 form 导出excle文件,在网上狂找了n个范例,但是都太复杂了,以下个人觉得比较简单,请各位高人指点:
declare
out_file text_io.file_type;
str varchar2(1000);
sys_date varchar2(20);
cursor s1 is
select a.prod_no||' '||c.product_name||' '||c.style||' '||d.inout_type_id||' '||to_char(b.qty_old_p)||'/'||to_char(b.qty_old_h)||' '||to_char(b.qty_p)||'/'||to_char(b.qty_h)||' '||to_char(TRUNC(sum(a.qty_std)/ MAX(c.CONVERSION_RATE)))||'/'||to_char(MOD(sum(a.qty_std),MAX(c.CONVERSION_RATE)))
from a,b,d
where a.prod_no=c.product_id
and a.prod_no = b.prod_no
and a.sales_no = d.IO_TYPE_ID
--and a.branch_no = b.branch_no
and a.yyyymm=b.yyyymm
and a.yyyymm=:B1.stk_year||:B1.stk_month
and substr(a.prod_no,1,1) not in('3','5')
and a.data_source_mark||a.sales_no <>'1062'
group by a.prod_no,c.product_name,c.style,d.inout_type_id,b.yyyymm,b.qty_old_p,b.qty_old_h,b.qty_p,b.qty_h
order by a.prod_no;
r1 s1%rowtype;
begin
synchronize;
SYS_DATE:=to_char(sysdate,'YYYYMMDDHH24MISS');
out_file:=text_io.fopen('D:\test.xls','w');
open s1 ;
loop
fetch s1 into str;
exit when not s1%found;
text_io.put_line(out_file,str);
end loop;
close s1;
text_io.fclose(out_file);
MESSAGE('资料导出完成!请查看D盘test.xls文件');
end;