Quick create export functionality

Serveral of my customers are asking for an export functionality to Excel or CSV. Have you ever experienced that? If so, how did you create that?

Let me tell you my solution. MS CRM 3.0 does offer SQL Reporting Services for Reporting. The reports which are generated can be exported to Excel and CSV. With a little bit of tuning, you can even render a report into one of these formats, without requiring the user to press the export button. In this post I'll show you how this can be done.

Let's say you're using the Adventure Works Cycle demo. Then create a report in SRS (there's enough info on the web on how to do this) and upload this report to CRM. You can upload such a report to crm by going to the Workplace area, select Reports and click "New". Now you can access this report via CRM, but also directly. To open this report directly, go to this url (where you enter your own servername, report folder directory and report name):
http://[your server]/ReportServer/?/[your report folder]/[your report]&rs:Command=Render

Now with sending parameters, you can export this to CSV or Excel. Modify the attributes of the report to contain:
&rs:Command=Render&rs:Format=CSV
&rs:Command=Render&rs:Format=Excel

The problem with the CSV, is that default the separator is a comma. You might want to change this to semicolon (;) or tab. To change this to tab, use the format hereunder:
&rs:Command=Render&rs:Format=CSV&rc:FieldDelimiter=%09

Since we know now how to export data, we can also make this link available for users. Unfortunately the isv.config does not allow us to enter an url as describe above, but we can make a simple aspx, or even html, page which does redirect the user to that url. Just add the redirection page to the webserver and add a link in the isv.config. You have now made a very easy to modify export without coding!

Update:
Placing a code like that in the ISV.config.xml is not allowed due to the : in the query string. Instead you will need to direct your code to a intermediate page which will redirect you to the report. You can do this by using a simple html page with a meta refresh:

<html>
<head>
<meta http-equiv="refresh" content="0;URL=http://localhost/ReportServer/?/Adventure+Works+Cycle+Demo_MSCRM/Export&rs:Command=Render&rs:Format=CSV&rc:FieldDelimiter=%09" />
</head>
</html>

No comments: