1. Create the form with Emp Data block in Tabular Style
2. Create Control Block having One Push Button
Properties Push_Button1
Name PB_BROWSE
Key board navigation no
mouse navigation no
Label Export
3.Write Following Code on Above button (When Button Press)Trigger
DECLARE
AppID PLS_INTEGER;
ConvID PLS_INTEGER;
last_rec number:=0;
cntr number:=0;
c number:=0; lno number:=1;
BEGIN
go_block('emp');
last_record;
cntr :=to_number(:system.cursor_record);
/* Start Microsoft Excel with spreadsheet emp.xls loaded. */
-- AppID := DDE.App_Begin('C:\Program Files\Microsoft Office\OFFICE10\excel.exe C:\emp.xls',
-- AppID := DDE.App_Begin('C:\Program Files\Microsoft Office\OFFICE10\excel.exe',
-- DDE.APP_MODE_MaxiMIZED);
ConvID:= DDE.Initiate('EXCEL', 'book1');
DDE.Poke(ConvID, 'R1C1', 'S.No.', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C2', 'Emp_ID', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C3', 'Name', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C4', 'Job', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C5', 'Mgr_ID', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C6', 'Join Date', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C7', 'Salary', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C8', 'Commission', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C9', 'Dept_ID', DDE.CF_TEXT, 1000);
go_block('emp');
if :global.lno<>0 then
lno:=:global.lno;
end if;
for i in 1..cntr loop
c:=c+1; lno:=lno+1;
go_record(c);
DDE.Poke(ConvID, 'R'||lno||'C1', c, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C2', :empno, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C3', :ename, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C4', :job, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C5', nvl(:mgr,0), DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C6', to_char(:hiredate,'dd/mm/rrrr'), DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C7', :sal, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C8', nvl(:comm,0), DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C9', :deptno, DDE.CF_TEXT, 1000);
end loop;
:global.lno:=lno;
DDE.App_Focus(AppID);
End;
4.Save and Compile then run the form
2. Create Control Block having One Push Button
Properties Push_Button1
Name PB_BROWSE
Key board navigation no
mouse navigation no
Label Export
3.Write Following Code on Above button (When Button Press)Trigger
DECLARE
AppID PLS_INTEGER;
ConvID PLS_INTEGER;
last_rec number:=0;
cntr number:=0;
c number:=0; lno number:=1;
BEGIN
go_block('emp');
last_record;
cntr :=to_number(:system.cursor_record);
/* Start Microsoft Excel with spreadsheet emp.xls loaded. */
-- AppID := DDE.App_Begin('C:\Program Files\Microsoft Office\OFFICE10\excel.exe C:\emp.xls',
-- AppID := DDE.App_Begin('C:\Program Files\Microsoft Office\OFFICE10\excel.exe',
-- DDE.APP_MODE_MaxiMIZED);
ConvID:= DDE.Initiate('EXCEL', 'book1');
DDE.Poke(ConvID, 'R1C1', 'S.No.', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C2', 'Emp_ID', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C3', 'Name', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C4', 'Job', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C5', 'Mgr_ID', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C6', 'Join Date', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C7', 'Salary', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C8', 'Commission', DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R1C9', 'Dept_ID', DDE.CF_TEXT, 1000);
go_block('emp');
if :global.lno<>0 then
lno:=:global.lno;
end if;
for i in 1..cntr loop
c:=c+1; lno:=lno+1;
go_record(c);
DDE.Poke(ConvID, 'R'||lno||'C1', c, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C2', :empno, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C3', :ename, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C4', :job, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C5', nvl(:mgr,0), DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C6', to_char(:hiredate,'dd/mm/rrrr'), DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C7', :sal, DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C8', nvl(:comm,0), DDE.CF_TEXT, 1000);
DDE.Poke(ConvID, 'R'||lno||'C9', :deptno, DDE.CF_TEXT, 1000);
end loop;
:global.lno:=lno;
DDE.App_Focus(AppID);
End;
4.Save and Compile then run the form
Respected SIR,
ReplyDeleteI want to export data in excel or notepad file with dynamic queries means result should be generate on change of query on run time...
Sir i want to import Data from Excel to Oracle Forms...
ReplyDelete