The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Automatically update Excel with form entries using Web Query
Excel is a great way to view form entries but downloading CSV files from the back end and importing them into Excel is a chore. Fortunately it can be automated and getting new data and reports is as simple as clicking Excel > Data > Refresh All
Excel has a Web Query that will scrape an HTML table (Excel > Get External Data > From Web). This has some undocumented limitations,
- Text strings longer than 48 characters may cause the addition of erroneous rows
- Text strings containing paragraph marks, line breaks or non-standard characters may cause the addition of erroneous rows
The Web Query works best is the only thing on the page it is getting the data from is a plain HTML table. The steps in our solution are,
- Create a blank page template
- Create a Formidable view of your form called MyView (say) that has these settings,
- View format: "All entries"
- Before content <table><tbody><tr> and then <th>field label</th> for each field you want to output
- Content: <td>[5]</td> for each field "5" for example that you wish to output
- dates should have be like [5 format="Y-m-d"] to promote accurate importation.
- After Content: </tbody></table>
- Create a new page called MyPage (say)
- Choose the "blank" template
- Add the view MyView
- change the slug to something obscure if necessary to enhance security
- View the page and make sure all the fields you want are there and the table is good. View the page source to check for any invisible issues.
- Open Excel
- Click Data > Get External Data > From web and enter the URL for your page
- https://mysite/MyPage
- After wizard has downloaded a preview of the table click Import and choose where to put the data
- Excel will populate the worksheet with a range containing your form data. You can refresh this at any time to see new entries
- If Excel fails to return data or you have extra rows you will need to visually inspect the source of the page and/or remove fields until you get Excel can import the data correctly. Typically you will need to remove free-text fields.
- Create Pivot Tables and Pivot Charts to analyse your data
How could this be made better?
Everything above is vanilla Formidable and Excel. A bit of coding on the WordPress side could change dates and times into ISO date time format and aggressively clean and truncate text fields to increase the reliability of import. Another useful possibility would be to generate CSV output which would increase portability and promote reliable ingestion of data.
May 25, 2016 at 1:17 pm
James, thanks for the great tutorial. Everythig works fine, but I have one issue. I hope you have a solution.
My form contains a text field, where users can put multiple lines of comments. When downloading the form entries into Excel, the multiple lies of the singel comment field are split over multiple rows in Excel.
Do you have any idea how Excel will treat the multi lie text field as one field/row?
Thank you very much,
Sytse
May 26, 2016 at 3:19 am
As you will have read above this is expected behavour.
I suggest that you may find that URLEncoding your free text content is helpful. This could then be URLUnencoded in Excel.
There are at least two approaches to this
URLEncode the free text fields when outputing into the view - I think that Formidable allows custom formatting
URLEncode a second copy of the data into a hidden field when collecting the data and output this hidden field into the view
My JavaScript is a bit weak at present so I can't give you code to do it. I would be really interested in how you get on solving this problem.
June 1, 2016 at 12:27 am
Thanks James.
As this gets more and more complicated (in my opinion due to MS Excel), I decided to switch to the 'out of the box' option to just download a CSV from the backend and open it in Excel.
Thanks for the help anyway. Probably I will use 'your' option in future cases.
Discussion closed.