Sunday 17 September 2017

WFFM : Customizing export form data to excel functionality

2 comments
In previous blog posts, I have explained how to create custom SQL provider and custom save to database action to store form data into SQL database. If you’re interested to know the context of the customization, checkout this blog post. In this blog post, I’ll explain how to customize export form data to excel functionality so that form reports include user’s browser information.

Environment Detail

Sitecore 8.2 update 5 (CMS only mode), Web Forms for Marketers 8.2 rev. 170807

Implementation

I’ve decompiled Sitecore.WFFM.Services.dll assembly to find out the code which invokes export form data to excel functionality.

It seems that we cannot override few methods inside of Sitecore.WFFM.Services.Pipelines.ExportToExcel.ExportFormDataToExcel class. So I created a duplicate copy of this class and added my custom logic to include user’s browser information into form reports.

Add a patch config file to configure custom export to excel functionality:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
  <sitecore>
    <pipelines>
       <!--EXPORT TO EXCEL--> 
      <exportToExcel>
        <processor patch:instead="processor[@type='Sitecore.WFFM.Services.Pipelines.ExportToExcel.ExportFormDataToExcel, Sitecore.WFFM.Services']" type="Website.WFFM.Pipelines.CustomExportFormDataToExcel, Website" />
      </exportToExcel>
    </pipelines>    
  </sitecore>  
</configuration>
That's it! Comments and suggestions are most welcome. Happy coding!

2 comments :