Monday, March 13, 2006

Add A Quick Export Link to the Worksheet Page

It's been a while since I posted a 'UIX hack' post. In fact, too long. So it was time for one. This one had actually been sitting with me for some time, but had been buried in my email inbox. Sometime back a bright fellow from our Viewer development team had conjured this up in response to a customer query and I thought it would be very useful to publish as a post. There are actually two parts to it - this is only the first part.

As I usualy do, I shall illustrate this with lots of screenshots.

This, on the left, is a screenshot of a Discoverer worksheet in Viewer. On the left you can see the 'Actions' pane with all the regular links. The one that I have circled in red is the one of interest. It says 'Quick PDF'. New, isn't it? What is it? Well... it's a quick link to let you export the current worksheet to the Acrobat PDF format without having to go to the 'Export' worksheet page, select the format of your choice, and then click the 'Export' button to initiate the export creation process. While the link says 'Quick PDF', it could just as well have said 'Get the PDF', 'Gimmee the PDF' or something else. The point of this link is that sometimes users have the urge to export every Discoverer worksheet in sight to some other format, like Excel, PDF, CSV, XML, etc... So a quick link saves time.

So what happens when you do click the 'Quick PDF' link? It's the same as selecting the PDF export format option from the Export formats list and click the 'Export' button. The worksheet is exported to the PDF format, and the generated PDF file is presented as a link for the user to click and open in Acrobat.
This page is the standard Discoverer Viewer page that you would see if you went through the Export page first.

This above is the exported worksheet inside Adobe Acrobat.

So, the next, and logical, question is how to get this in the first place? The 'Quick PDF' link, and how to tie it to the PDF export action. As it turns out, it's really, really simple.

If you are not familiar with UIX or how Discoverer UIX files look like, I would suggest you read some of my earlier UIX hack posts - that will save me time and you some unwanted grief. Links to those posts are present at the end of this post (link).

Now that you have read those posts let's get down to brasstacks.

Browse to the folder where you your BI (or App Server if you don't have the standalone BI install) Oracle Home is. Then browse to the "Oracle_BI_Home\j2ee\OC4J_BI_Forms\applications\discoverer\discoverer\".... folder as shown in the screenshot below. This is the folder where all the UIX files used in rendering Discoverer Viewer (and Discoverer Portlet Provider pages also for that matter) are located.

Find the 'worksheet.uix' file and make a backup of it before you even so much as take a long look at it. (Working with files that you do not have a backup for is like looking at the sun without wearing sunglasses. Sooner or later something bad is going to happen). Having done that - taking a backup - open the file using a text editor like Notepad, TextPad, vi, JEdit, etc... Scroll down the file till you come to lines that look like the screenshot below.
Just above these lines insert the following lines (if the lines appear garbled it's because Blogger is not yet smart enough to escape < and > with with & l t ; and & g t ; )
<rowLayout>
<contents>
<cellFormat wrappingDisabled="true" >
<contents>
<link text="Quick PDF">
<boundAttribute name="destination">
<concat>
javascript:discoSWP('aForm','
<contextProperty select="ui:contextURI" />
<dataObject select="ACTION_SERVLET" source="constants" />
exportdata?event=ExportData&exportType=7');
</concat>

</boundAttribute>
</link>
</contents>
</cellFormat>
</contents>
</rowLayout>


Having done that, save the Worksheet.UIX file, close it, and login to the Application Server control. Restart the OC4J_BI_Forms instance. This may take a few minutes, so be patient: good things come to those who wait for them (better things may come to the impatient ones....).
Once the component has restarted re-login to Viewer and open any worksheet. You should see the 'Quick PDF' link now. If not, close and restart your browser (this seems to be an issue more with Firefox than IE).


So, there are probably two questions, at least, that you are itching to ask.
How could Australia score 434 and still end up on the losing side (link)???

The second question is how do you change the link so that it generates an Excel or HTML or Pivot Table or TXT or any other export? Because, you would have noticed that the URL associated with the PDF export action has an id associated with the exportType URL parameter (...exportdata?event=ExportData&exportType=7). The intrepid ones among you could start cycling through all values from 1 to a crore and see which ones map to which export formats. For the patient ones, I shall be posting another post, later this week, where I list out all the different export format ids, including how to customize the Export formats dropdown list.

Related UIX Hacks posts:
UIX Hack 1 - Removing the 'Connect Directly' section
UIX Hack 2 – Remove the Last Refresh Date from Discoverer Portlets
UIX Hack 3 - Removing the 'type' column from a portlet
UIX Hack 4 - Removing the worksheet breadcrumb

The Disclaimer:
  • I am NOT suggesting that you go around and muck around with these UIX files.
  • Any changes you make to UIX files are unsupported.
  • Oracle Support will not support your installation if you run into problems as a result of making changes to these UIX files.
  • You will have to reproduce any errors on an instance without these UIX changes for Oracle Support to help you.
  • Any upgrades or patches you apply may overwrite custom changes you make to your UIX files.
Changed the post time and date to Mar 13, 3:03pm