The Export Table View to CSV add-on allows you to export tables as a CSV file (comma-separated values) on the front-end of your site.
A CSV file can be read by spreadsheet programs like Microsoft Excel, Apple Numbers, and Google Sheets, and programs that can read text files like Notepad++.
Export Tables to CSV brings the full power of Views, with their sophisticated filtering system and flexibility, to exporting Formidable entries. You can customize the content with inline conditional statements, shortcodes, custom text, and anything else you can put in a View.
With this add-on, you can:
- Allow your users to export their own data.
- Create a search form of your products and let people export their results.
- Give admins robust filtering options to export entries with customized content.
- Do a daily backup of the entries of your critical forms.
There are several ways to export tables as a CSV file on the front-end:
Download and Setup
- Install and activate Formidable Forms Pro if you haven't already done it.
- In your WordPress admin, go to Formidable → Add-Ons and click the Install button for the Export View to CSV add-on.
- Create a Table View for your form.
- Choose how you want to export the CSV file for the table View. You can add an export link below a View, use the shortcode, or schedule automatic exports.
Add export link to download
To generate an export link for a user to download the table View as a CSV file, follow the steps below.
- In the View settings, scroll down to the Metabox → Export View Settings section.
- Select the Show Export Link with View checkbox.
- If you would like a custom filename, fill in the Filename box. If you don't enter anything in this box, the title of the View will be used. By default, the filename will also include a number representing the date. This allows a person to export the same View multiple times into separate files instead of overwriting the same file each time.
- The Export Link Text is the label on the export link. Customize the link text to something like "Download your results" or "Export your entries". Otherwise, the link will use the text "Export to CSV".
- If your view includes filters that get values from the URL, you can decide whether to include the URL parameters for the export. You have two options
- Yes (more flexible, not recommended for Views with sensitive data) - If selected, URL parameters will be available for the export to filtering and display. Including params is not recommended for Views with sensitive data as these params can be seen and changed easily using browser tools.
- No (more secure) - Selected by default. This option is more secure. Depending on the filters in your View, the export may include different data.
- Preview your View. You should now see an export link to download the CSV file.
- If you have set the View entry number limit to 10, the CSV export is limited to 10 entries.
- If you have set the View page size limit to 20 entries per page, all relevant entries will be downloaded to the CSV export.
Use the shortcode
The [frm-export-view] shortcode allows you to create a link to download a table View to a CSV file.
Insert the [frm-export-view view=100] shortcode on a page, post, View, or any other location on your site where WordPress shortcodes are processed.
- view: The id or key of the View that will be exported as a CSV file.
Change 100 to the id or key of the View you want users to be able to export.
- label: The text of the link to export the CSV. If a value isn't entered, the Export Link Text setting from the View will be used. If no value has been set, "Export to CSV" will used.
[frm-export-view view=100 label="Download my book recommendations"]
Schedule automatic exports
You can automatically export a table View as a CSV file. The location on your server, and frequency of the export is up to you.
- Go to your Formidable → Global settings → Export Views page.
- Schedule CSV Export: Select the View(s) that you would like to export.
- Frequency: Choose when you want to schedule the export by days or months, then enter the number. Months are at thirty-day intervals and not calendar months.
- Format: Choose the format for your CSV file. UTF-8 is the default format. If special characters in your export are not appearing correctly, try a different formatting option. It includes the following options:
- UTF-8 with BOM
- Column separation: Enter a single character to use as a separator in your export. By default, a comma will be used.
- Destination directory path: Enter the path to a folder on your server to store the exports. Include the root, which is listed beneath the setting for your convenience. If you don't add a location, the default wp-content/uploads/formidable/exports folder will be created automatically. The default location is an excellent place to save your exports.
Disable Automatic exports
To stop automatic exports of the Table Views, follow the steps below.
- Go to your Formidable → Global settings → Export Views page.
- In Schedule CSV Export, uncheck the Views you no longer want to automatically export. Uncheck all to stop all automatic exports.
- Click Update.
Exporting with parameters
Params can expand what you can do with Views. They can be used to display and filter the view content. Depending on your view filters, if params are changed or removed, people may potentially see data they shouldn't.
The Export Table View to CSV add-on gives you the choice of how you would like to work with parameters. Below are the following options.
- Choose not to export with params
- In the View Export settings → Include params with your CSV export setting, select No. With this option selected, parameters are not added to the link to export the View.
- Choose to export with params
- In the View Export settings → Include params with your CSV export setting, select Yes. With this option selected, params from all sources are added to the link.
- Export some params but not others
- In the View Export settings → Include params with your CSV export setting, select Yes.
- In the After Content box of the View (after the closing table tags), set the values of the params you don't want to be added to an empty string with [frm-set-get]. e.g. [frm-set-get color=""]
Params included with export
You can set parameter values in different ways:
- In the URL:
- In form and View shortcodes displayed above the export View link:
[display-frm-data id=100 color=red]
- Using [frm-set-get]:
If you choose to export with params, all params will be shown in the export link. This will include those in the URL, the [frm-set-get] shortcode, and form and View shortcodes.
It's relatively easy for someone who knows how to use browser developer tools to see, save, and change the link used to export a View. The key data in the export link is obfuscated to make it difficult to change the link and export different data. Several security measures are included to protect sensitive data.
Change link expiration time
For security purposes, created links can only be used for a limited time. The default is 24 hours. If the link is included in an email, including a note that the link expires may be helpful.
If you want to change the expiration time for visitors who are not logged in, use the frm-export-view-link-expiration-hours hook.
Invalidate all links
You can invalidate all links by changing your site salts in the wp-config.php. Learn how to change WordPress Salt Keys. Any saved export links will no longer work.
File protection is automatically added to the automatic exports folder, so the CSV files with your exports cannot be accessed directly using the file URL. This also prevents your CSV exports from being indexed and searchable by Google and other search engines. If the automatic exports folder already has an .htaccess file, it won't be replaced.
* Please note that file protection is limited to Apache servers. File protection on Nginx servers is not yet supported.
Logged in users
Links created for logged in users have extra protection to ensure someone else doesn't download the data. When a link is created for a logged-in user, the link will only function for that user. No other logged in or logged out user will be able to use the link.
Create admin dashboard for exporting
Formidable has built-in CSV exports of entries in the admin area. When exporting a CSV via a table View, you can create an admin dashboard with robust filtering that's tailored to your needs and preferences. To create an enhanced admin dashboard to export your entries, follow the instructions below.
- Create a Table View for your form.
- Create a custom search form to filter your View as needed.
- Make sure that your View's visibility is set to private. This setting can be found on the right sidebar of your View builder.
- Add the search form and View shortcodes on a page on your site.
- Use the free Hide This plugin or frm-condition with the has_role shortcode to only show the search form and search results View to admins.
No Views available for export
The Export Table View to CSV add-on will evaluate whether a View can be exported or not when the View is saved.
- If your table View was created before you activated the add-on, go to the View builder and save the View again.
- If your View has a closing table tag in the Before Content box, remove it and save the View again.
No export link
If the View with any allowed parameters has no entries, the [frm-export-view] shortcode will not show an export link.
No CSV file created
If you have set up an automatic export but you're not seeing any CSV files in your directory, try looking in your wp-content/uploads/formidable/exports directory. This is the default location for files to be saved. If there are any issues with the destination directory path you selected, your exports will be saved in the default location.
Make sure your table View has entries. If the table View doesn't have entries, a CSV file won't be created.
If your CSV export is missing content from the downloaded Table View, here are a few things to check:
- Do you have any stray content that's outside of td or th tags?
- For the headings, only content that is inside th tags, which are inside tr tags, will be included.
- For the content rows, only content that is inside td tags, which are inside tr tags, will be included.
- Have you formatted your table rows and cells properly? If not, their content won't be included.
- HTML markup, links and images can't be included in the content. If you want to save an image link, show the link on its own in the View instead of inside an img tag.
Related developer hooks
Learn more about the list of available hooks.
- Change the length of time a download link is valid with frm_export_view_link_expiration.
- Adjust the exported content with frm_export_content.
- Customize the headings in the export with frm_export_csv_table_heading.
- Change the filename with frm_export_view_csv_filename.
- Prevent an apostrophe from being prepended to cells starting with a +, = or @ character with frm_export_view_risky_characters.
- Remove or change parameters that are added to the Export to CSV link with the frm_export_view_query_args.
- Change the line break of CSV with the frm_export_csv_line_break.
- Separate columns of CSV with semicolon with the frm_export_csv_column_sep.
- Add an action allows you to do something after Export View options are saved with the frm_export_view_options_saved.