I have a script that turns a submitted form into a PDF and emails it automatically but I can't seem to get my head around if it is possible to implement a function i would like: -
User fills in Google form
Submits form
This creates entirely new spreadsheet based on same headers from the form
Emails thie spreadsheet as an .xlsx attachment automatically to a specific email address
Is this possible? I feel like I am missing a simple way to do this but I am having a moment of noobishness! :-)
1, 2, 3 - all quite possible.
4 - Not as such. There's no support in Google Apps Script for converting a Sheet to Excel format. However you could produce a CSV file which would be understood by Excel or any other spreadsheet program, and email that as an attachment.
Generating a CSV is covered in one of the Apps Script tutorials. See Saving a selected Range to a CSV file from Tutorial: Interacting With Your Docs List.
An example of attaching files from Drive is provided in the documentation for MailApp.sendEmail().
Related
I am working on a script that is standalone. It collects its baseline data from a google sheet bound to a form. In the form submission, excel documents are uploaded. While I can access the link for the excel document(google downloads the excel into your drive upon submission and inserts the drive link into the google response sheet), I am having difficulty looking into and extracting anything (exact cell values, ranges, indexes, etc) from the excel doc.
I have tried using various functions from the sheets and spreadsheets classes and continue to get errors. Some suggestions I've found say the excel document needs to be converted into a google sheet before the app script can access it, or that app script won't allow you to work with such a document if it is not bound to your script (since that allows you to activate it)(I can't bind the excel doc because it changes upon every new submission of the form).
Has anyone ever compiled a similar code and figured out how to access an unbound, non-google doc?
Let me know if you need error codes or script snippets. I just wasn't sure if this was a syntax problem or a google suite trick spot that needed extra code that I probably haven't found cause I'm new to this platform.
From the question
Has anyone ever compiled a similar code and figured out how to access an unbound, non-google doc?
Scripts in Google Apps Script aren't "compiled" by the script writer in the sense that it's done when developing something in other platforms.
To get data from a file hosted in Google Drive, first the script should get that file by using the Drive Service (Class DriveApp) or the Drive Advanced Service.
The next part depends pretty much on the Excel file format. If it's an xlsx file, then usually the most convenient is to convert the file into an Google spreadsheet as this will make possible to use the Spreadsheet Service (Class SpreadsheetApp) to read the data from it.
If you don't want to convert it to a Google spreadsheet file, or it can't be converted the the "basic" means because it's using an incompatible format (like a xls file format), then you will need to use an library or an external service to parse the Excel file content.
function getalldataonsheet() {
const ss=SpreadsheetApp.openById('ssid');//you provide id
const sh=ss.getSheetByName('sheetname');//you provide sheet namme
const rg=sh.getDataRange();
const vs=rg.getValues();//2d array
return vs;//this return 2d array
}
There are restrictions for passing parameters in client to server communication
I have created a Google form with few responses. I want to download those responses as PDF format into my local pc using a script run by Apps Script. I can't find any apis in Apps Script to do so.
Any ideas? Thank you.
When you have a Form, it will save your responses in a Sheet, as described here. You can export that sheet as PDF following step 2 in this tutorial using the UI.
If you want to use GAS, you can follow this tutorial, to show you how to create an add-on for it. You can also follow this answer to get a single sheet as a PDF.
However, I believe the suggestion of doing it with the UI will work best for you, since each form has only that Spreadsheet associated to it, and it will have only one sheet.
Okay. Multiple people use the scanpet app to create csv files of 3 columns [uniformly structured, no headers in csv].
I'd like them to email the created file to a gmail account, then go to a google form. I realize for this to work it's have to be done after each email submitted and that is okay... please read to end.
I'd like to make a google form with only one option, just to enter a record to trigger an event. Link the form to a google sheet. I'd like this sheet to house the script I'm asking help for in the script editor, and the google sheet to then have two other tabs named Transfer and MailOrder each with the same 3 columns as the csv files.
After the employee sends the file he completes the google form.
script triggers on form submit, and will grab the the latest csv attachment from gmail and depending on the subject line of the email (Mail Order or Transfer) add the values to the existing data entries under the tab with the same name as the subject line.
I currently have a google form which appends responses to an Excel format file. I have also attached a script to it which parses the response and emails the results...
Building on that, how would I do the following additional steps:
Keep the current behavior which appends responses to the default EXCEL spreadsheet format file.
Convert the default EXCEL spreadsheet format file to a file called allresonses.txt (CSV format)
Saves the current responses as mytest.txt (CSV format) and have this emailed as an attachment. (Currently I am able to only add them to an email using my script)
Any help would be appreciated
Thank you
The solution is to use scripts , I check the google forms script examples.
Quick walk through:
1. Just create a form in google forms and add your questions.
2. Create a script on the add script page (of course google for the correct script or check the developer forum examples)
3. While the default is a spreadsheet format you can select one of the supported types (again I check the google developer examples,they're somewhat dated but do still work.)
All sorted now.
Thank you
I have a spreadsheet that I use for work that I send out on a weekly basis. The spreadsheet itself is pretty simple, but it does contain an updating chart.
I want to set up a script that will send the spreadsheet (with included chart) as part of the body of the email. I've seen several threads no here about emailing spreadsheets as a PDF, but I can't find any about sending the sheet as the body of the email.
Any help would be greatly appreciated!
This is really just a matter of pulling the data you want using the Spreadsheet Service, then inserting it into a message as an HTML table for the Gmail service. The chart can be embedded by getting its contents using the getBlob() method, then inserting it using the inlineImages option.