Skip to main content

Command Palette

Search for a command to run...

Supercharge Reports with HTML Expressions in Oracle APEX

Updated
Supercharge Reports with HTML Expressions in Oracle APEX
R

Rodrigo is a Senior Oracle Developer at QV Systems. He is an experienced software engineer with emphasis in analysis, design and development of bespoke Oracle applications utilising development tools such as APEX, PL / SQL, jQuery, javaScript, CSS and JSON for a variety of international businesses. Rodrigo speaks regularly at Oracle community events and enjoys creating APEX plugins and writing blogs.

Oracle APEX makes it easy to get data on screen fast, but often, the default tabular output isn’t enough. What if you want to highlight statuses, add icons, or display badges all without writing complex SQL or JavaScript? HTML Expressions: a powerful feature that lets you transform your reports with just a few lines of markup and template directives.

What Are HTML Expressions?

An HTML Expression in Oracle APEX allows you to control how a column’s data is displayed by wrapping it in custom HTML, referencing column values, and using conditional logic—all within the APEX UI. You’ll find the HTML Expression field in many components, including Interactive Reports, Classic Reports, Cards, and Lists.

Key Benefits:

  • Separation of concerns: Keep UI logic out of your SQL queries.

  • Security: Underlying column data is used for downloads and filtering, not your HTML markup.

  • Flexibility: Add icons, badges, tooltips, and more dynamically.

How to Use HTML Expressions

Step 1: Open Page Designer

  • Select your report region (Interactive or Classic Report).

  • Click the column you want to format.

  • Find the “HTML Expression” property.

Step 2: Reference Column Values

  • Use #COLUMN_NAME# to insert the value of any column in your SQL query.

Example: This displays the employee name in bold, followed by their job.

<strong>#ENAME#</strong> – #JOB#

Going Further: Template Directives

APEX’s Universal Theme supports powerful template directives for conditional logic and dynamic content.

Conditional Formatting

Show different output based on column values.

<strong>#ENAME#</strong> – 
{case JOB/}
  {when PRESIDENT/}
    <span style="color:red;">#JOB#</span>
  {when MANAGER/}
    <span style="color:blue;">#JOB#</span>
  {otherwise/}
    <span style="color:green;">#JOB#</span>
{endcase/}

Best Practices

  • Keep SQL clean: Avoid embedding HTML in your SQL queries. Use HTML Expressions for UI logic.

  • Hidden columns: If you need to generate complex HTML or values, create a hidden column in your query and reference it in the HTML Expression.

  • Security: The HTML Expression is only rendered in the browser. When users download the report, only the raw data is included, not your HTML, reducing the risk of leaking markup

Check out more examples here.