Hopefully, this fits in with this thread. I know it is not 100% java, but the functions are similar.
I am making a lesson plan script that uses a Goolge form to create a report in Google spreadsheet that is identical to the lesson plan template we use at my school. I went through all the tutorials and hundreds of lines of sample code, and I cannot find this answer. Searching for this answer is even more frustrating because it just returns simple directions to save a file from the tool bar!
In my script, I have a trigger that does the following function on Form sumbission:
Delete row 2 (this allows the data in row 3 to stay constant with new forms sumbitted)
Email (email choices are on the form)
I have the code for this down, and it works fine, (but there is a problem with the 5 minutes delay that Google has in its spreadsheet when it uploads the data to a html. So I have to find a solution that saves the report to the google drive.)
My focus is to create a sheet (report) and have a script function that automatically saves sheet 2 in google docs.
When I do a search for google script save function, I get toolbar help.
This is the only sample script I could find, it runs, but it is not saving what it should and where it should:
function saveAsCSV() { // Prompts the user for the file name var fileName = Browser.inputBox("Save CSV file as (e.g. myCSVFile):"); // Check that the file name entered wasn't empty if (fileName.length !== 0) { // Add the ".csv" extension to the file name fileName = fileName + ".csv"; // Convert the range data to CSV format var csvFile = convertRangeToCsvFile_(fileName); // Create a file in the Docs List with the given name and the CSV data DocsList.createFile(fileName, csvFile); } else { Browser.msgBox("Error: Please enter a CSV file name.");} }
Is there a saveAs function that uses a similar syntax to the above in the script I am trying to write?
If I can find the correct command, this will go much smoother when trying to fix the rest of the script: Saving as a pdf, how to just save sheet 2 which is the report and not the entire spreadsheet).
Any help would be great,
Thanks
-seg