Making CSV files display in the browser window (inline) using Excel
Important: You need Plone 2.1.4, Plone 2.5.1 or later to get the various Office documents rendered inline in the browser. Earlier versions of Plone will cause them to be downloaded instead of rendering them in the browser window.
The reason we wanted this was for a customer that has most of their data in CSV files, and needed to display them using Excel on their web site and intranet.
Technically speaking, the problem is that instead of displaying the content inline, Plone sends it to the browser with the MIME type
text/x-comma-separated-values (which is correct), and Excel does not intercept this request to display it in the browser window, causing a file download instead.
The way to work around this is to do the (slightly evil ;) trick of mapping the CSV file to the Excel MIME type instead. In general, this causes no problems (people without Excel still get to download the file), but isn't 100% clean if you consider the standards. This is also why it is not done by default in Plone.
OK, let's get started:
- Go to the ZMI in your site
- Go to
- Search for
csvon the page, and check the checkbox next to the entries that match. We are going to delete the existing ones. Strictly speaking, this isn't necessary in the current version of Plone, since the Excel MIME type is declared earlier and takes precedence, but I'm being paranoid about it in case the order changes — you can skip this step if you want. In my instance, the CSV entries were:
Delete Selected Itemsat the bottom of the page with all the CSV-related entries selected.
Now there are no entries that handle CSV. Verify this by doing a search for
csv on the page again.
Then we modify the MIME type that for the Excel file, so the CSV files are rendered inline in the browser window instead of causing a download:
- Click the
Microsoft Excel spreadsheetentry (search in page to locate it)
csvon a separate line
*.csvas a separate line
- Click the
Uploaded files with the CSV extension should now have the MIME type
application/vnd.ms-excel, and open in Excel — inside the browser.