Offline download of Google Spreadsheet that saves Google script code as well - google-apps-script

What's an efficient way of making an offline backup of a Google spreadsheet so that it includes its Google script files? It seems that if I use the Download as Microsoft Excel File feature, the downloaded xlsx file does not include any Google script that is part of the spreadsheet.
I saw a post about a command line tool called "Clasp" by Google that can be used but I was hoping to use something that is not so arcane.

Related

How to stop Google Drive from automatically saving csv's imported into a Google Sheets document

I often make spreadsheets in Google Sheets by importing a collection of csv files. But whenever I import a csv file into a Google Sheets document, the csv file is uploaded to my Google Drive as well.
As a result, I have a huge number of csv files in my Google Drive that I don't want.
Can I stop this from happening? I want to import the csv into the Google Sheets document but I don't also need the csv file in my Google Drive.
A follow-up question is: if I can't prevent the csv from being uploaded to my drive, can I delete the csv from my drive without affecting the Google Sheets document?
This question is related to this one How to stop Google Sheets automatically saving downloaded CSV files to Google Drive, but they asked the question incorrectly, and never followed up with a corrected question.
The CSV files being uploaded to the Google Drive is necessary. It is due to the fact that Google Sheets will only look for the source files to be imported either from your personal Google Drive or from other people's Google Drive that are shared with you.
Suggestion
As for your issue on multiple csv files, you can create a script to automatically delete csv files from your Google Drive. However, the only available feature in Google Apps Script is to move the said files to a folder using the File.moveTo(destination) function since the removeFile(child) function was already deprecated. Afterwards, you may use the setTrashed(trashed) function to send the files to the trash folder.
References:
You may view the following links for further details on how to apply the suggestion.
removeFile(child)
moveTo(destination)
setTrashed(trashed)
Google Apps Script Deleting Google Drive Files in Folder Example

How to load data from a .htm file with google apps sciript

I set up a automated job via SAP (SM36) where I recieve a report as an attachment on a regular basis via e-mail (GMail). This is working fine but I just received an .htm file from SAP so that I need to transfer the data into a google or excel sheet. Unfortunately, it is not possible to receive the file directly as a .xlsx file.
I know how I can get the .htm file out of gmail into my drive via GApps Script. The next step is to get the data out of this file into a google spreadsheet. I wasn´t able to figure out how I can do this so I ask you to help me with this regard.
How can I get the data out of the report (.htm file) into a google spreadsheet or directly into a excel sheet via Google Apps Script?
Many thanks in advance!
Best regards,
search(query)
getMessages()
getAttachments()
getDataAsString()
openById(id)
setValues(values)

can you open a excel file directly with google sheets api

how can I open a excel file directly with google sheets api
Not to my knowledge, however, using the Drive API you can upload and convert an Excel file to Sheets format automatically. This could then be used by the Sheets API. This may or may not work as a substitute in your use case.
Well you can read a .xlsx file as a binary blob from Google Apps Script API. So if you want to read the xlsx formatted file and do all the work of interpreting it yourself, then sure you can. But that's essentially writing the entire MS Excel interpreter in Google Script.

is it possible to download GMail attachment to local folder?

i want to download attachment from gmail and save it to local folder using google script. i did some research about this and i could't find any solution.
so far, i managed to save gmail's attachment to google drive only.
var attachmentBlob = attachment[0].copyBlob();
var file = DriveApp.createFile(attachmentBlob);
folder.addFile(file);
or, is it possible to create a google script to auto download file from google drive?
need some advice.
As #Sujay already mentioned you cannot download a file to a local folder using Google AppScript because GAS runs server-side.
You have already taken a good step with the code to save the attachment as a file to your Google drive.
To answer your sub-question 'is it possible to create a google script to auto download file from google drive?', you do not need a script to do that, that is what the Google Drive Desktop App (https://www.google.com.ng/drive/download/) does exactly.
It syncs all the files you add to your drive to your local-pc. You can also edit Google Drive preferences to sync select folders only, in your case that might be the drive folder referenced in your folder variable.
GAS runs on the server side, and only has access to Google's internal architecture. To save locally it'll need to create some kind of a blob and trigger a download within your browser. not sure if you can do that.

Google Apps Script to initate browser download when clicking on a Google Drive file

I have some particular files stored on my Google Drive with the extension of "bch". I need to be able to have a user click on this file in Google Drive and have it initiate the browser download prompt.
I was thinking that the way to do this would be to create a script that has the file information passed to it as a parameter and then execute the download request. I was hoping to define the file extension in the script so all files with this extension would be defaulted to run this script/app in Google Drive.
Has anyone done anything like this? If you could point me to some Google Apps Script examples I would greatly appreciate it. Thanks!