Skip to main content

Displaying the File Type Icon in Oracle APEX Reports


When a file gets uploaded, the icon of the file type is displayed without opening the file. This has been inspired by Microsoft - Outlook. Here I am giving an elegant way for displaying the file type icon in Oracle APEX reports.

Step 1: Create a table by using below script,

CREATE TABLE ebs_project_files
  (
     id            NUMBER,
     project_id    NUMBER,
     filename      VARCHAR2(4000),
     file_mimetype VARCHAR2(512),
     file_charset  VARCHAR2(512),
     file_blob     BLOB,
     file_comments VARCHAR2(4000),
     created_on    TIMESTAMP (6) WITH local TIME zone,
     created_by    VARCHAR2(255),
     updated_on    TIMESTAMP (6) WITH local TIME zone,
     updated_by    VARCHAR2(255),
     PRIMARY KEY (id) USING INDEX ENABLE
  );

Step 2: Populate some records on ebs_project_files.

Step 3: Create a new blank page.

Step 4: Create a new Classical Report region to the page. (Refer below script)

SELECT data.id,
       '<span class="t-Icon file-icon fa '
       || Decode(Substr(Upper(data.filename), -4), '.PPT',
          'fa-file-powerpoint-o',
                                                   '.XLS', 'fa-file-excel-o',
                                                   '.DOC', 'fa-file-word-o',
                                                   '.PDF', 'fa-file-pdf-o',
                                                   '.GIF', 'fa-file-image-o',
                                                   '.PNG', 'fa-file-image-o',
                                                   '.JPG', 'fa-file-image-o',
          Decode(Substr(Upper(data.filename), -5), '.PPTX',
          'fa-file-powerpoint-o',
                                                   '.XLSX', 'fa-file-excel-o',
                                                   '.DOCX', 'fa-file-word-o',
                                                   '.TIFF', 'fa-file-image-o',
                                                   'fa-file-o'))
       || '"></span>'                                              AS icon,
       data.filename,
       data.last_action_on,
       data.last_action_by
FROM   (SELECT epf.id,
               epf.filename,
               epf.file_comments,
               epf.file_blob,
               epf.file_charset,
               epf.file_mimetype,
               lower(Nvl(epf.updated_by, epf.created_by)) last_action_by,
               Nvl(epf.updated_on, epf.created_on) last_action_on
        FROM   ebs_project_files epf
        ORDER  BY created_on DESC) data
WHERE  rownum <= 10; -- Print only 10 records for test purpose

Step 5: Go to report attribute ICON and set Escape special characters = Yes

Step 6: Change the style of the icon by adding below CSS to the page in inline CSS section.

Go to Page => CSS => Inline

.file-icon.fa-file-powerpoint-o,
.file-icon.fa-file-excel-o,
.file-icon.fa-file-word-o,
.file-icon.fa-file-pdf-o,
.file-icon.fa-file-image-o,
.file-icon.fa-file-o {
    padding: 4px 8px;
    text-align: center;
    color: #FFF;
    border-radius: 2px;
}

.file-icon.fa-file-powerpoint-o {
    color: #D24726;
}

.file-icon.fa-file-excel-o {
    color: #217345;
}

.file-icon.fa-file-word-o {
    color: #2A579A;
}

.file-icon.fa-file-pdf-o {
    color: #F40700;
}


Output: Then your output would then display like this,
The demo is here.

That's it.

Happy APEXing!!!...

References:

Comments

Popular posts from this blog

Printing Page Numbers in RTF Template [Oracle BI Publisher]

Here I am giving an example to print the page numbers dynamically in the RTF (Rich Text Format) template. Step 1:  Go to page footer and copy and paste the below script. Page |  <?fo:page-number?>  of  <?fo:page-number-citation:xdofo:lastpage-joinseq?> <fo:page-number> :   This is the object, which is used to represent the current page-number. <?fo:page-number-citation:xdofo:lastpage-joinseq?> :  This is the syntax, which is used to represent the total number of pages. Step 2:  Load the XML and preview the result. Output: That's it. References: fo:page-number Printing Page Number Code in Oracle XMLP RTF Template

Oracle Application Express Views (APEX)

Application Express Views Search SELECT * FROM apex_dictionary WHERE column_id = 0; View Comment Parent View APEX_APPLICATIONS Applications defined in the current workspace or database user. APEX_WORKSPACES APEX_APPLICATION_ALL_AUTH All authorization schemes for all components by Application APEX_APPLICATIONS

Save Selected Interactive Grid Records into a Collection - Oracle APEX

Here I am giving an example to save selected interactive grid records into a oracle apex collection. Step 1: Create a new blank page. Note: Mine was page 20. You will need to update reference to " P20 " with your page number if it's different. Step 2: Create a new interactive grid report region to the page using below query. Set Static Id "EmpDetails" to the region. SELECT  *     FROM   ( SELECT  emp . empno ,                emp . ename ,                emp . JOB ,                dept . dname department ,                dept . loc  LOCATION ,                mgr . ename  manager ,                emp . hiredate ,                 nvl ( emp . sal , 0 )  salary ,                 nvl ( emp . comm , 0 )  commission            FROM  eba_demo_chart_emp emp ,                eba_demo_chart_dept dept ,                eba_demo_chart_emp mgr           WHERE  emp . deptno = dept . deptno             AND  emp . mgr      = mgr . empno  ( + )           ORDER   BY  emp . ename