Create Group Report Using HTML in Oracle Apex
Create Group Report Using HTML in Oracle Apex
Topic Introduction: In this tutorial, we will show how to create a PDF Group report using HTML & PL/SQL in the dynamic content of Oracle Apex. Here we will use the Departments and Employees table of the HR Scheme. This report will be grouped by department name. I have given code for HTML formatting as an example. Can modify it in your own way.
Follow the step to complete this work.
01. Create a Blank Page.
02. Create Region: Region Type Dynamic Content.
03. PL/SQL Function Body returning a CLOB: Write the PL/SQL code on the box.
Example code is given here to understand
declarel_result clob;beginl_result := l_result || '<div id="PrintArea">';l_result := l_result || '<h1>Department wise Employee List</h1>';l_result := l_result || '<style>table, th, td {padding:5px;}</style><table border="1" cellspacing="0" style="width: 100%;"><thead><tr><th rowspan="2">Department</th><th colspan="4">Employee</th></tr><tr><th>ID</th><th>First Name</th><th>Last Name</th><th>Salary</th></tr></thead><tbody>';for i in (SELECT D.DEPARTMENT_NAME, E.EMPLOYEE_ID, E.FIRST_NAME, E.LAST_NAME, E.SALARY, count(*) over (partition by E.DEPARTMENT_ID order by E.DEPARTMENT_ID) rowspan_dept, row_number() over (partition by E.DEPARTMENT_ID order by E.DEPARTMENT_ID) rn_deptFROM OEHR_EMPLOYEES E,OEHR_DEPARTMENTS DWHERE E.DEPARTMENT_ID=D.DEPARTMENT_IDorder by E.DEPARTMENT_ID)loopif i.rn_dept = 1 thenl_result := l_result ||'<tr><td rowspan="'|| i.rowspan_dept ||'">'|| i.DEPARTMENT_NAME ||'</td><td>'|| i.EMPLOYEE_ID ||'</td><td>'|| i.FIRST_NAME ||'</td><td>'|| i.LAST_NAME ||'</td><td>'|| i.SALARY ||'</td></tr>';elsel_result := l_result ||'<tr><td>'|| i.EMPLOYEE_ID ||'</td><td>'|| i.FIRST_NAME ||'</td><td>'|| i.LAST_NAME ||'</td><td>'|| i.SALARY ||'</td></tr>';end if;end loop;l_result := l_result || '</tbody></table></div>';return l_result;end;
04. Save and Run this page
This code will make a department-wise employee list group will be department wise. If you face any problem completing work, please feel free to contact me, I hope I can help you to complete this task
Create a PDF Group Report Using HTML & PL/SQL in The Dynamic Content of Oracle Apex |
No comments