i_reporttitle VARCHAR2(200) := 'My excel';
COL1 VARCHAR2(2);
COL2 VARCHAR2(8);
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('AQUI_BLOQUE');
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', :bloque.campo1);
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', :bloque.campo2);
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');
ole2.release_obj(ExcelWorkSheetID);
ole2.release_obj(ExcelWorkSheetsID);
ole2.release_obj(ExcelWorkBookID);
ole2.release_obj(ExcelWorkBooksID);
ole2.release_obj(ExcelID);
END;