get spreadsheet URL - url

I have a problem in my reporting, i create every day a google doc tracker where all the stack holders in my department update their work progress in it, so i have plenty of spreadsheets to monitor which is a hassle, here is what im trying to do, I'm trying to create a big google doc tracker where i can have an access over date applied in the normal spreadsheets, all what i need is the spreadsheet's URLs that exist in my google drive to be retrieved in this big tracker, with this i'll be able to drive all the needed data from the normal trackers.
PS: I'm not good with google scripts.

You can use the Drive Service to get a list of files with MIME type "application/vnd.google-apps.spreadsheet" using getFilesByType. This returns a FileIterator, which you can use to individually get each Spreadsheet file. From there, just use getUrl() to find the URL's. The FileIterator link has examples of how to loop through all the matching files.

Related

Can Google Sheets be set up to propogate templates to existing children based on them?

I'm working for a company who want me to move their shared drive (NAS) to Google Drive get us working collaboratively.
Currently we have a central spreadsheet which has a bunch of information about each aircraft we work on, which mail merges into word docs. When we need to do a specific thing (like weigh the aircraft) we need to generate a document to store with the details on it. We open a template word doc and use the mail merge deature to find the reg of the aircraft and Word's mail merge pulls in the rest of the info into the doc. Great stuff!
We're moving to Google Drive to work more collaboratively. Is there a way of doing this same thing on GDrive? I can see ways of having a google sheet pull info from a master spreadsheet in this way, but not google Docs (which will work better because of the way you can format tables).
My research shows that this is easy with a google sheet but I need to use a google doc really, for the formatting flexibility.

How to read excel file from user and generating Google Sheet file

I need to allow user upload excel (xlsx) file and then generate a Google Sheets file using Google Scripts (the generated file uses the input file values, process them with certain formulas and provides another excel file as output based on all processing)
I am currently doing the task in a simple desktop application (using MS Excel etc.), but problem is I have admin rights and I want other people to do the same on their PCs but they dont have admin rights, so please help me with this, whats the best way I can implement it via Google Sheets. I need following to do:
Get an XLSX file from user
Read two columns using google sheet script.
Process the read values and create a new google sheet file with 6/7 columns
Plz help as I am not looking for a ready made code but a head start, as I have never worked with google scripts before.
First you need to study the basics of Apps Script in general, and of the SpreadsheetApp, DriveApp and Advanced Drive Service in specific.
The steps to write your code would be
retrieving the excel file on your Google Drive
retrieving its blob
creating a new file of the mimeType GOOGLE_SHEETS with the contents of your blob
Once you create a Google Spreadsheet - process it with the SpreadsheetApp methods to delete spare contents/ create a copy with only the desired contents.
Here you can find useful samples.
Note: It might make sense to retrieve the columns of interest before
converting them to Google Sheets, but this is not something you can do
with Apps Script or a Google API since they do not have methods to
edit Excel files.

How to update google spreadsheet via sheets API v4

I'm facing an issue within updating of existing spreadsheet on google drive, without using a batch update (right now I'm not sure whether it is even possible)
I already have existing spreadsheet with some data, then I retrieve file from google drive via
Drive drive = new Drive.Builder(TRANSPORT, JSON_FACTORY, credential)
.setApplicationName(APPLICATION_NAME)
.build();
drive.files().list().execute().getItems()
I easily match my file by the name and then I just want to update the spreadsheet in the founded file.
Sheets service = new Sheets.Builder(GoogleNetHttpTransport.newTrustedTransport(), JSON_FACTORY, credential)
.setApplicationName(APPLICATION_NAME)
.build();
Spreadsheet spreadsheet = service.spreadsheets().get(file.getId()).execute().setSheets(new ArrayList<>());
Here I get spreadsheet from file which match the name and then I just want to put there empy sheet (for example).
There is first point, where I'm not sure how to correctly "update" the spreadsheet on drive, because I cannot use
service.spreadsheets().create(spreadsheet).execute();
and I don't want to use batch update, because I already have set the spreadsheet content via setSheet() method.
I think it should be finalized with following:
Permission permission = drive.permissions().get(file.getId(), permissionId).execute().setType("anyone");
drive.permissions().update(
spreadsheet.getSpreadsheetId(),
permissionId,
permission
).execute();
I was checking the google API here:
https://developers.google.com/drive/v2/reference/permissions/update
and here:
https://developers.google.com/sheets/api/guides/batchupdate
but they are using batch update.
What I am curious is why there is setSheets() method, which seems to be easily to use for updates, when I already created my sheets, but it seems that I just cannot simply update spreadsheet in existing file.
What is also interesting that every time I use the drive.perm.update, it creates a new file(with spreadsheet that I wanted to update) which actually doesn't make much sense to me.
So is there any chance to simply update file on drive and just use the spreadsheet method?
This statement by Jay Lee in this related SO post will give a clear insight:
The Google Drive API is meant for generic file / folder interactions. For directly modifying Google Spreadsheet data, the Google Sheets API would be the better choice.
Furthermore, to update Google spreadsheet, you may want to check Reading & Writing Cell Values which describes the basics of using the spreadsheets.values collection. It was mentioned that,
If you need to update formatting or other properties in a sheet, you will need to use the spreadsheets collection, which is described in Updating Spreadsheets.
For more information, please see Batch update operations and examples are shown here.

When to Call Something "Docs" and When to Call it "Drive"

So, a quick background. I make productivity apps (specifically CRM and Project Management). And I love the docs, spreadsheet and presentation products made by Google. Not surprisingly, my products have done a lot of "things" with Google Docs for a long time:
Create "native" (ie. Docs/Spreadsheets/Presentations) documents
Use native documents as templates
Link and modify permissions of any file in Docs/Drive
Upload any arbitrary file
etc.
What I'm confused about is what does Google want me to do on the labels on the buttons in my app. Right now, they all say "Google Docs". You're linking any arbitrary file to a presentation, you're linking it from "Google Docs". You're exporting a spreadsheet of time sheet entries, you're exporting it to "Google Docs". You upload a PDF, you uploaded it to Google Docs. Etc.
What I'm confused about is that, and correct me if I'm wrong, but I don't think it is a complete switch over to "Drive." I still see labels on the Google site for Google Docs. So, this is what I think the breakdown is:
If it is a Google "native" file, then it is Docs, else it is Drive. Thus, if your uploading any arbitrary file, that button should refer to drive. But if you are exporting a spreadsheet of data to the Google Spreadsheets format, then that is Docs.
Is this right at all? Does Google have some information somewhere?
Disclaimer: personal opinion
I would use Drive everywhere, except when specifically talking about the collaborative word processor provided in Google Drive, that is the Google Doc.
I would also make sure that all my integrations use the new Google Drive API.
There is reasonably good guidance here: https://developers.google.com/drive/branding
Google Docs and Google Drive are two seperate products from Google. They can work together, but they are still their own individual products and should be called their respective names when being used

Using Google Spreadsheet as DB for apps

I want to use Google spreadsheets to store data online so multiple people can enter and maintain data, then publish or export (csv, xls, ods) the sheet for their application. What is the easiest way to process the sheet? If the data can be accessed as a link the updates could be immediately reflected in the client's app.
This article Data Scraping Wikipedia with Google Spreadsheets discusses using Google spreadsheets as an application platform.
It already has features that allow you to share the spreadsheet with multiple editors, as well as the ability to define forms that you can invite people to fill out who's results will be entered into the spreadsheet as a row.
Just in case its still vaguely of interest 5 months later, there is a SQL-like wrapper language for Google Spreadsheets at:
http://gqlx.twyst.co.za
Its very much an alpha release - but maybe its of some use or perhaps the code could give you some ideas.
I think if I am clear on your requirements, you want to store your data online in a Google Spreadsheet where multiple people can access that right? Then you want an app to use that data? Correct me if I am wrong.
It is possible to have Google spreadsheet as a database and the client app can directly access that data through APIs - spreadsheet APIs . If you want a simple link where people can go and update - you can also have a web app using google apps scripting. very simple to use and would solve your purpose too , why to export your data to ods, xls, csv, make your app directly over Google Spreadsheet. Would be maintainable too.

Resources