One of my projects at work called for a tabular form, but the users wanted to have access to a lot of information. We're talking over thirty–and that makes the form almost unusable, since the user constantly has to scroll back and forth to see all their information. Only four of the columns are editable; the others are informational only. Now, most of these columns are only marginally useful, so I convinced the users that we could move them into a modular pop-up window. The form now displays “just” thirteen columns (that's still fairly wide, if you ask me, but the nine display-only columns are always useful, so it makes sense to keep them). One of the display-only columns, through the magic of jQuery, includes a link to open a modular dialog with the other data. Well and good.
…but. (This wouldn't be an interesting post if there wasn't a but, right?) To help my users parse the data efficiently, I added an export to CSV link to the form. And, of course, they want to have all the data in the CSV, not just the columns that are displayed.
When you're editing the column attributes of a report or a tabular form, APEX gives you a few options that seem relevant to this: Show Column, Include in Export, and Display As. If you set Show Column to Yes and Display As to anything other than Hidden, the Include in Export flag properly controls whether or not the column appears in the CSV. But (there's that word again) if you set Show Column to No or Display As to Hidden, the column isn't visible in the report–or in the CSV, regardless of the Include in Export flag. We need to look elsewhere for a solution.
Luckily, there's a post by Jari Laine (nice guy, by the way; you can check out his APEX demo site here–there's lots of useful stuff on it!) on the Oracle forums that gives us the answer: set the column to display as normal, but give it a condition that causes it to only render when it's being exported to CSV. Set the Condition Type to PL/SQL Expression, and use this for the expression:
NVL(:REQUEST, 'MY_REQ') LIKE 'FLOW_EXCEL_OUTPUT%'
(Note that Jari's post has a semi-colon after the expression, but APEX throws an error if you include it). And, just like that, everyone's happy. Yay!