Your spreadsheet or Excel file is frequently updated, and you don't want to update it manually each time. This article explains how to refresh your Awesome Table app automatically.
If your data is frequently changing (regularly updated by a script, for example) it can be useful to use Awesome's table auto-refresh feature. It will load the latest data from your source spreadsheet (without refreshing the page itself).
This feature is to be used with a javascript template. You will have to use a function called "AT_reload();".
It can be used in two different ways; to have your data refreshed regularly or to use a one time refresh.
Refresh data automatically
Using this function with a parameter (a number of seconds) will automatically refresh your data every X seconds.
Add a refresh data button to your app
When using this function without a parameter, it will refresh your data only once. You can call this function in a custom script or, as widespread use, to use with a refresh button:
This feature uses a javascript template.
It can be used in two different ways:
- To have your data refreshed automatically
- To use a refresh data button
Refresh data automatically
From your data Excel File, add a new sheet:
Rename your new sheet > add the script:
Copy/paste the following script in your Excel file if you want to reuse it:
<script>
AT_reload(30);
The '30' parameter of the functions is the rate in seconds at which the app will automatically refresh. You can change it according to your needs.
If your data source already contains another ‘Template’ sheet with HTML, CSS or JavaScript code, add the script on a new column:
- <script> has to be on the first row
- AT_reload(30); has to be on the second row
Go back to your AT app, click ‘Advanced Parameters’.
Under ‘Template sheet’ write the name of your new sheet (in our example our new sheet names ‘Template’). Then, write the Template range > click ‘Update app’:
Add a refresh data button to your app
When using this function without a parameter, it will refresh your data only once. You can call this function in a custom script or, as a really common use, to use with a refresh data button:
Copy/paste the following script in your Excel file if you want to reuse it:
<button onClick=”reloadData()”>Refresh data</button>
<script>
function reloadData(){ AT_reload();}
If your datasource contains already another ‘Template’ sheet with HTML, CSS or JavaScript code, add two new columns:
- <button onClick=”reloadData()”>Refresh data</button> has to be on column A / second row
- <script> has to be on column B / first row
- Function reloadData(){AT_reload();} has to be on column B / second row
Go back to your AT app, click ‘Advanced Parameters’.
Under ‘Template sheet’ write the name of your new sheet (in our example our new sheet names ‘Template’). Then, write the Template range > click ‘Update app’.
A button ‘Refresh data’ will appear on your AT app: