0

Is there anyway to send an Excel .xls version of the NEW Google Sheets to automatically (when triggered by a time frame like for example 'Every Sunday at 9:00pm')?

I have searched many posts in many sites and seen only examples for the old google docs. What I am doing is using tasker on my phone to update a time sheet on Google Forms, and I want to make a copy of the sheet, name it using the current date, and then email it to my supervisor on Sunday.

I found this on iGoogle and use it by changing the URL, but Excel keeps saying the file is corrupt.

Here is the link with the code I was trying to use.

Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57
  • The new SS can be converted to xls, see this post answer: http://stackoverflow.com/questions/23402693/oauth-error-when-exporting-sheet-as-xls-in-google-apps-script. The part that sends the email and build the file name from the current date is rather simple and you'll find a lot of code examples ( including the answer below; -) – Serge insas Aug 19 '14 at 06:48
  • Here's a similar question with an up-to-date answer. http://stackoverflow.com/questions/31809987/google-app-scripts-email-a-spreadsheet-as-excel – Christiaan Westerbeek Oct 08 '15 at 15:06

1 Answers1

0

I feel like the example for sendEmail() does a good job explaining but I'll break down the steps for you since I'm not the best coder:

  1. To get the file you can use getFileById() or getFilesByName
  2. Get the Date for your time zone (See Below)
  3. Create an options object ( See Below)
  4. Send Email comannd

Code to get time and date from your Spreadsheet:

var timeZone = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTimeZone();
var sDate = Utilities.formatDate(new Date(), timeZone, "MM/dd/YYYY HH:mm:ss");

Example of options Object:

var option= {
        from: " YOUR EMAIL ADDRESS",
        name: " YOUR NAME"
        attachments: file.getAs(contentType)
    }; 

For more info about content type see this

Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57
user3431106
  • 127
  • 1
  • 5