WEB상에서 PLSQL로 EXCEL FILE만드는 예제
=======================================
CREATE OR REPLACE PROCEDURE toExcel IS
CURSOR c1 IS
SELECT empno, ename, job, sal
FROM emp;
counter NUMBER(3) := 1;
counter2 NUMBER(3) := 2;
BEGIN
-- Tell that it's Excel who shall get the output
owa_util.mime_header(ccontent_type => 'application/vnd.ms-excel');
htp.p('ID;ORACLE');
htp.p(';');
htp.p('; Formatting');
htp.p(';');
-- Align the three first columns to the left
htp.p('F;C1;FG0L;SM0');
htp.p('F;C2;FG0L;SM0');
htp.p('F;C3;FG0L;SM0');
-- Align the last column to the right
htp.p('F;C4;FG0R;SM0');
htp.p(';');
htp.p('; Title Row');
htp.p(';');
htp.p('C;Y1;X1;K"Empno"');
htp.p('C;X2;K"Ename"');
htp.p('C;X3;K"Job"');
htp.p('C;X4;K"Sal"');
FOR l1 IN c1 LOOP
htp.p(';');
htp.p('; Row '||counter);
htp.p(';');
htp.p('C;Y'||counter2);
-- Put in the data
htp.p('C;X1;K"'||l1.empno||'"');
htp.p('C;X2;K"'||l1.ename||'"');
htp.p('C;X3;K"'||l1.job||'"');
htp.p('C;X4;K"'||l1.sal||'"');
counter := counter +1;
counter2 := counter2 +1;
END LOOP;
htp.p(';');
htp.p('; Format Column Widths');
htp.p(';');
htp.p('F;W1 1 10');
htp.p('F;W2 2 10');
htp.p('F;W3 3 10');
htp.p('F;W4 4 10');
htp.p('E');
END;
/
from oracle
원본출처 : http://211.209.69.159:8000/Orastudy/board.jsp?bbs=tiptech&pg=1&seq=353&act=view
|