(Thanks to [Henrik Fransas at NetRelations](🔗) for this example.)
In Optimizely you can create custom reports and use the built-in reports in the admin view. The following example shows how to create a custom report of existing pages on a website and how to export the report to Excel using EPPlus.
Start by creating a Controller that looks like this:
This controller is a GuiPlugin which is shown in the report menu and uses the URL _/existingpagesreport_. The controller is protected so you have to be part of the administrator group to use it.
For the URL to work, add a route to it in _global.asax.cs_:
Create a simple view and make sure it shows up in the report center.
Add a ViewModel with the necessary properties:
Create a helper class to make a request against Optimizely like this:
Update your index action to create an instance of the View model and assign all page types to it:
The action in the controller that handles this looks like this:
It returns the view if the export values are not **true**.
To export the report to Excel, use **EPPlus** and create a function in the same class like this: