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

Slack Signup
Newsletter Optin
Help Desk

Automatically update Excel with form entries using Web Query

Labels

This Discussion is public

Notifications

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,

  1. Create a blank page template
  2. Create a Formidable view of your form called MyView (say) that has these settings,
    1. View format: "All entries"
    2. Before content <table><tbody><tr> and then <th>field label</th> for each field you want to output
    3. Content: <td>[5]</td> for each field "5" for example that you wish to output
      1. dates should have be like [5 format="Y-m-d"] to promote accurate importation.
    4. After Content: </tbody></table>
  3. Create a new page called MyPage (say)
    1. Choose the "blank" template
    2. Add the view MyView
    3. change the slug to something obscure if necessary to enhance security
    4. 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.
  4. Open Excel
  5. Click Data > Get External Data > From web and enter the URL for your page
    1. https://mysite/MyPage
    2. After wizard has downloaded a preview of the table click Import and choose where to put the data
  6. 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.
  7. 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.

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

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.

 

 

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.