BLOG • DIGITAL INSIGHTS
Sitefinity's built-in Excel export can be extended to include custom data. This post shows how to use IoC to replace the default ExcelExporter and add item owner information to every exported row, with working code for both the bootstrap step and the custom exporter class.
Every now and then we need to export some content type from Sitefinity to Excel. Sitefinity allows content item exporting for dynamic content types. However, not many people know this can also be extended to include custom data. In this short post I will show you how to export items along with their owner information.
Sitefinity uses IoC, and luckily the default exporter is registered - so extending and replacing it is straightforward.
The interface we need to implement is IDataItemExporter. However, in this case it is easier to extend the class Sitefinity provides rather than implementing everything from scratch. That class is ExcelExporter, found in the Telerik.Sitefinity.Data.Utilities.Exporters namespace.
As usual, we start with the bootstrapped event handling in Global.asax.cs:
Next, implement the class itself:
The built-in Sitefinity exporter exposes a few methods - the two we care about are:
Build the project and run it. If you now go to the Sitefinity backend, navigate to Administration - Module Builder, and click Actions - Export content for any module, you will see the owner of each item included in the exported Excel file.
IOwnership interface check to make sure the content type has an Owner property - which should be true for all dynamic content items, but it is good practice to ensure your code has everything it needs.Explore more insights and case studies from our team.