Link Search Menu Expand Document

Build and use a robust export feature

Use a library for exporting your index views to XLS or CSV.

Marketplaces have many table views

Your admins are likely to have access to a lot of them. Those views won’t show all the captured data.

In the beginning, you won’t know what information the team needs. And later there won’t be enough space for all of it.

Not having access to all the fields also makes it difficult to do ad-hoc analysis. Therefore, users often copy-paste those tables into Excel to do other transformations. For example, they’d like to know the hourly distribution of orders during a campaign.

But copy-pasting is tedious and error-prone.

And putting all the fields in the interface makes it more impossible to do day-to-day tasks, besides being slower and uglier.

So, add a way to export (nearly) all the data

Each table view should have the ability to export to Excel.

When models get new fields, they must be added to the export as well.

A simple but robust way of building export is with a uniform template and white-listed attributes. The template would be the same for all models. Each model would have a list of attributes to be exported. The template loops through the entries and calls each white-listed attribute in order.

In Ruby, the call method makes it possible to white-list method names as well.

This approach can last a very long time. Eventually, you can override the generic template to include additional features - such as graphs or derived fields.

You can even add multiple different views to the same list, each containing different columns. For instance, the order export can have one template that follows the bank template, another that exports only the ratings, and another that has the entire kitchen sink.

That makes it easier for the end-users to access more of the available data

If your users can export data to Excel, they can use a powerful existing tool that they already know.

There is little point in duplicating everything Excel can do.

They can do ad-hoc analysis for things that aren’t in your dashboard. They can provide better feedback on which fields to add to the dashboard. And they don’t have to wait for fields to be added to do their job.

It also makes audits and due diligence easier.

NOTE: While I specifically write Excel, nowadays, Google Drive works as well. Users aren’t as familiar with OpenOffice alternatives, and to be frank, they are not as good. Exporting to .csv can also be fine, but it does not have formatting options.

Suggest an improvement to this page (