Content Report Generator

blog header image

I helped a client with a cool little report generator that can give them an easy overview of all their content - and related metadata, that can be opened in excel and easily sorted, filtered and aggregated. Here it is.

When you have a lot of content, produced by many editors - and especially across many sites, pages and blocks - it's quite important to get a good overview over your content to answer some essential questions like:

  • Who is producing all the content
  • Where is the old content
  • How are my review and approval rules implemented and used
  • What is outdated and should be removed
  • Which content needs to be translated
  • And many other kinds of content governance.

Of course there is the good old Episerver Report center. And thanks to this great example by Henrik Fransas, it's pretty easy to figure out how to build your own reports and export them. But since those reports are generated on the fly (in the request) you can end up waiting for that download for a long time - if you don't run into a time out. Sure, not a problem when you have a few hundred content items - but not so fun when you are dealing with many hundred thousands (which is when you really need the overview). So, for this report I took the approach of letting a scheduled job generate the report and then make it available for download.

Also, most of the existing reports in the report center are pretty much focused purely on the content in the content repository. But these days there is quite a lot more interesting meta-information around the content. Who has access to it, how many versions does it have, where is it used, who is reviewing it and so on - all stuff that could help you achieve better content governance.

In the past I've done prototypes, examples, demos and experiments using PowerBI for this sort of task, but in this case an excel file is fine to keep people happy most of the time, so why complicate things.

Here is the initial code I came up with - feel free to use and modify it to fit your reporting needs:

It will generate a report as a media file in Episerver, in an automatically created folder called "Internal Reports". I advice that you after the initial creation set access rights on the folder to ensure that the reports can only be accessed by specific roles!

report.PNG

For the report I included a bit of the code used in my previous post for gathering information about who is configured to review the content - and a bunch of other code to get a list of places that use the content, and the versions of the content.

To generate the excel format document I use the EPPlus library, easily added to your project through nuget.

A fairly easy modification I would recommend might be to generate plain CSV files instead (I ended up doing that for the client, but haven't updated the example code yet). Using EPPlus you build up the excel file in memory and write it in the end - which I expect could be a problem if you excel files turns really big. CSV files you can generate, write and flush to disk line-by-line, hence eliminating memory issues.

Here you can find an example Report from a standard Alloy site:

ReportsExample.xlsx

Recent posts