We have a Google Form that saves its submits to a Google Spreadsheet.
Using the Script manager, how do we export that spreadsheet contents or the latest form submit message to a local Excel spreadsheet or tab-delimited text file on my harddrive?
This would be a 2 step process:
- catch form submit or spreadsheet change event and externalize the data into the cloud Drive.
- place that data on my local hard drive.
How do we do #1 and/or #2, using the Google spreadsheet script?
We have created a OnFormSubmit callback function on the spreadsheet, but we can only log the event message (the form submitted data) to a popup window in Drive.
function OnFormSubmit(e) {
var sheet = SpreadsheetApp.getActiveSheet();
var row = SpreadsheetApp.getActiveSheet().getLastRow();
var newMessage = e;
Logger.log(newMessage);
}
There is a CreateFile method, but its not clear how I could use that.
I was able to use the code below to create a tab delimited text file on my Google Drive that's a copy of the original Google spreadsheet that collects the data from the form.
The code is triggered on the Google spreadsheet change event. This allows the code to run when a new form is submitted, but it also will update the text file on any change event in the spreadsheet. This allows you to edit existing entries.
Once the file is on your drive, a simple scheduled batch file can copy the file to any location outside your google drive.