Showing Tabs on Export to Excel

Back To Blog

One of the most common Clarity customization requests we get is displaying tabs when reports are Exported to Excel.  Standard Clarity installations output the grid to Excel with the same elements exposed.  For example, if the Clarity grid shows grid lines, then the Export to Excel will show grid lines.   The same holds true for freeze frame, protection, groupings and the tab display.  Unlike the other elements however, the tab display isn’t really necessary for the usability or formatting of the report or template – it’s simply information and not having the tab is frustrating for users.

Personally I wish Clarity would add this as an option – having the ability to alter the state of the grid on Export for these elements would be very useful.  Unfortunately I doubt this request is high on their list of enhancements, so we need to take matters into our own hands.  By adding only a few lines to a couple of Clarity base code files we can show the tabs on every Export to Excel!

Let me start by saying modifying the Clarity base code is dangerous business and if you don’t feel comfortable doing so feel free to contact us to help you out.  If you do want to proceed I insist you first take a backup of any files you will be modifying and perform any changes and testing in a development environment first.  Also, upgrading to newer releases of Clarity or applying Service Packs may remove these changes forcing you to add them again.

Today we are going to be discussing Clarity 7, although we have done the exact the same logic for Clarity 6.  There are 2 files that need modification to fully support this functionality.  The first is Web\Scripts\Templates\export.js which handles the standard Export to Excel from the a template / report.   The second is Web\MyTabs\MyTabs.js which handles the My Tabs Export to Excel.  I’m going to provide details for the changes required in the first file in this blog entry, but I will post the modified versions of the both files in the Resource area for anyone interested in the full solution.

  • Step 1: Backup Export.js file
  • Step 2: Open the file in an text editor and find the function titled ExportGrid.
  • Step 3: Find the following row within the function.

 var result = PAGE.clarityX.Documents.ExportDocument(myDoc, action, C$T.schema.fileExport.reuseExcel);

  • Step 4: Insert the following 2 lines above the row in step 3.

var bDisplayTabs = GRID.ActiveWindow.DisplayWorkBookTabs;
GRID.ActiveWindow.DisplayWorkBookTabs = true;

  • Step 5: Find the following row within the function.

CWINDOW.PopStatus();

  • Step 6: Insert the following line above the row in step 5.

GRID.ActiveWindow.DisplayWorkBookTabs = bDisplayTabs;

  • Step 7: Save the file.  Note: Clarity marks these files as read-only, so you’ll need to alter this attribute of the file before saving.

 

The resulting function should look as follows:

 

So that’s!  The second file is almost as easy – so give it a try as well.  If you have any problems feel free to send me an email or comment on this post and we’ll get it fixed it quickly.  Please also contact us if you have any additional customization you would like done to make your Clarity solution the best it can be!