PROCEDURE test IS i_reporttitle VARCHAR2(200) := 'My excel'; COL1 VARCHAR2(2); COL2 VARCHAR2(8); COL3 VARCHAR2(8); COL4 VARCHAR2(15); COL5 VARCHAR2(50); COL6 NUMBER(3,1); COL7 NUMBER(3,1); COL8 DATE; COL9 NUMBER(2); COL10 NUMBER(2); COL11 NUMBER(2); COL12 NUMBER(9,2); COL13 NUMBER(9,2); COL14 NUMBER(9,2); COL15 NUMBER(6); /*dno number(2); dn varchar2(14); dl varchar2(13);*/ r number := 2; c number := 1; i_orientation VARCHAR2(200) := '1'; i number :=1; /* definiton for commonly used variables and constants and exceptions */ ExcelID ole2.obj_type; ExcelWorkBooksID ole2.obj_type; ExcelWorkBookID ole2.obj_type; ExcelWorkSheetsID ole2.obj_type; ExcelWorkSheetID ole2.obj_type; ExcelCellID ole2.obj_type; ExcelFontID ole2.obj_type; ExcelPageSetupID ole2.obj_type; ExcelArgs ole2.list_type; BEGIN ExcelID := ole2.create_obj('Excel.Application'); ExcelWorkBooksID := ole2.get_obj_property(ExcelID, 'Workbooks'); ExcelWorkBookID := ole2.invoke_obj(ExcelWorkBooksID, 'Add'); ExcelWorkSheetsID := ole2.get_obj_property(ExcelWorkBookID, 'Worksheets'); ExcelWorkSheetID := ole2.invoke_obj(ExcelWorkSheetsID, 'Add'); ExcelPageSetupID := ole2.get_obj_property(ExcelWorkSheetID, 'PageSetup'); ole2.set_property(ExcelPageSetupID, 'Orientation',i_orientation); ole2.release_obj(ExcelPageSetupID); loop go_block('exporttoexcel'); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col1); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+1); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col2); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+2); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col3); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+3); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col4); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+4); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col5); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+5); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col6); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+6); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col7); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+7); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col8); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+8); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col9); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+9); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col10); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+10); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col11); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+11); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col12); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+12); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col13); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+13); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col14); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+14); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.col15); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); exit when :SYSTEM.LAST_RECORD = 'TRUE'; next_record; i := i+1; end loop; /* loop go_block('exporttoexcel'); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.deptno); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+1); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.dname); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i); ole2.add_arg(ExcelArgs,c+2); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', :exporttoexcel.loc); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); exit when :SYSTEM.LAST_RECORD = 'TRUE'; next_record; i := i+1; end loop; */ ExcelArgs := ole2.create_arglist; ole2.add_arg(ExcelArgs,i+1); ole2.add_arg(ExcelArgs,1); ExcelCellId := ole2.get_obj_property(ExcelWorkSheetId,'cells',ExcelArgs); ole2.destroy_arglist(ExcelArgs); ole2.set_property(ExcelCellId, 'Value', 'END'); ExcelFontId := ole2.get_obj_property(ExcelCellId, 'Font'); ole2.set_property(ExcelFontId, 'Bold', 'True'); ole2.set_property(ExcelFontId, 'Size', '10'); ole2.release_obj(ExcelFontId); ole2.release_obj(ExcelCellId); ole2.set_property(ExcelID, 'Visible','TRUE'); -- ... and release the allocated resources because they are no longer used by forms ole2.release_obj(ExcelWorkSheetID); ole2.release_obj(ExcelWorkSheetsID); ole2.release_obj(ExcelWorkBookID); ole2.release_obj(ExcelWorkBooksID); ole2.release_obj(ExcelID); END;