Showing URLs in DataTables Excel exports
The Excel button on a DataTables View writes link addresses into the spreadsheet, so you don’t need any code to get URLs in the file.
If your file holds the link text but no addresses, update DataTables to version 3.13 or newer.
Turn on the Excel button #
The Excel button is off in a new View.
- Edit your View.
- In the Settings box, click the DataTables tab.
- Under Buttons, make sure Enable Buttons is checked, then check Excel.
- Click Update.
Link and file columns in the Excel file #
| Column | What the cell holds | Example |
|---|---|---|
| File Upload with an image | The image’s address | https://example.com/gk-download/…/ |
| File Upload with any other file | The file name, then the file’s address | care-sheet.pdf (https://example.com/gk-download/…) |
| Website | The link text, then the address | example.com (https://example.com/perennials/bellflower) |
| Phone | The number as the table shows it | (555) 014-2290 |
| Any field with Link to single entry checked | The value, without the entry’s address | Bellflower |
| Link to Single Entry or Link to Edit Entry | The link text, then the address | View plant (https://example.com/view/plants/entry/85/) |
| A link inside a Paragraph or Custom Content field | The link text, then the address | winter care guide (https://example.net/tropicals/winter-care) |
When the link text is the address itself, as in a Website field with Shorten Link Display unchecked, the file holds the address once.
Images that don’t open in a lightbox #
An image column holds the image’s address only while the image opens in a lightbox, which is the default. When Enable lightbox for images is unchecked on the View Settings tab, the cell holds the image’s alternative text instead. Unless the field’s Alternative text setting says otherwise, that is the field label, so every row reads Photo.
To export the address in that case, open the File Upload field’s settings and check Display as a Link:. The cell then holds the file name and its address, as in bellflower.jpg (https://example.com/gk-download/…/). The table on the page shows the file name as a link instead of the image.
Exporting file addresses that keep working #
GravityView links uploaded files through secure download addresses that contain /gk-download/. Each address stops working one hour after GravityView creates it, so the file addresses in an exported spreadsheet stop opening within the hour.
For images, PDFs, audio and video, you can export the file’s permanent address. Open the File Upload field’s settings and check Use Direct File Path for Media:. Anyone who has a direct address can open the file, so leave this setting off for files that should stay private. Using direct file paths for uploaded media in GravityView explains the difference.
If you added the code from an older version of this page #
This page used to give a code snippet for the View’s Custom JavaScript field. Remove it: in DataTables 3.14 it puts HTML tags into the other columns, replaces values linked to their entry with the entry’s address, and adds the table’s hidden sorting column to the file.