Web Forms for Marketers provides a great feature called form reports which gives you access to every web forms form submission. Sitecore provides you with two formats for exporting these records. You can export them to an Excel document (.xls) or to an XML document (.xml). However, your users might want to export the records to other formats. This post will describe how to add your own custom export button using a format of your choosing.
Start by creating a ‘Large Menu Combo Button’ under /sitecore/content/Applications/Modules/Web Forms for Marketers/Form Reports/Ribbon/Home/Export in the core database. The ‘Click’ field of the button you just made will correspond to a custom command that we will make later. The other fields are straight forward.
You should now see your button in the export chunk when viewing a form report.
Now you are ready to wire up your custom command that will do the work of exporting the selected records. Begin by creating a class that will handle doing the work of exporting your records. This class should inherit from either Sitecore.Forms.Core.Commands.DataCommand, Sitecore.Web.UI.XamlSharp.Continuations.ISupportsContinuation or Sitecore.Forms.Core.Commands.Export.ExportToXml. I personally would recommend inheriting from ExportToXml since much of the leg work has been done already by Sitecore. I’ve gone ahead and posted the decompiled ExportToXml command so you can see how it is working.
There are a lot of moving pieces here that need to be taken into account. Here is a class to get you started:
You’ll notice that on line 59 there is a reference to /path/to/MyExportControl.aspx. This will be in charge of streaming our content back to the browser so our user can download it. Lets show how that is done.
Now that you have the functionality ready to go. It’s time to add the command to Sitecore so the ‘Click’ field on our combo button will be able to find it. We do this using a config file such as the one below.
You should now be able to export form submissions in a the format that you have chosen.