Uploading an XLSX converting and replacing a current spreadsheet - google-apps-script

Just a general question, I would like to create a user upload form that would convert an .xlsx to the corresponding Google Sheets version and then replace a currently existing sheet on my drive. The main question and aspect that I'm not sure is achievable is replacing a current google sheet. Is a project like this even achievable in a reasonable manner? The reason I want to replace it is because the KeyID for that sheet is used in a couple other app scripts for a website. Thanks for the suggestions and advice.

Yes, this is possible. About being "reasonable", well... I think it is, it's not a single line script, but this is not the most simple task either.
But from what I understood from your use-case (other app script for a website), I think it's better if you enhance your other scripts to either look for the newest sheet on a given folder or fetch the ID from somewhere that you can update from the "form upload" script. Also, by doing this, you'll avoid getting inconsistent data in the middle of an update.

Related

Is there a way to move a file from google form submission into another folder based on a rows criteria in google sheets

is there a way to move a file from google form submission into another folder based on a rows criteria in google sheets?
I would appreciate any assistance. Thanks.
If I understood correctly your question has two parts: first you want to match a criteria in the responses Sheet. Then, you want to move a file from a folder into another one. If my understanding of the issue is correct, then you can achieve your goal with these easy steps.
In the first place you can use the TextFinder class to look for a match in the response Sheet. If there is a match, then the files should be moved from one Drive folder into another. To run that move you need to open the file first by using DriveApp.getFileById(). Then you can use File.moveTo() to move it to the other folder by providing the folder identifier (it could be done by using DriveApp.getFolderById()). Please, feel free to ask me any additional doubts.

Script to get a GooglePhoto using filename stored in GoogleSheets

I have a Googlesheets that has in one of its columns the filename (as "filename.jpg") of pictures stored in GooglePhotos (and/or Google Drive). I would like to have a script that would show me the selected picture when I click on a given cell of that particular column.
I'm quite familiar with Googlesheets Scripts and have looked at Google Photos API but don't know where to start.
Has anyone developed something like this and is willing to share? Any hints will be very much appreciated.
Many thanks in advance
I have a similar solution. You have to start from Browser API and this existing repo https://github.com/gsuitedevs/apps-script-samples/tree/master/docs/dialog2sidebar
But before that you have to realize the next flow:
Get a string
Try to search the file with this string
Return the file or undefined

SelectBox in Google Script?

I am a little bit new to Google Script so apologies if my question is silly. I have the following user scenario:
- on a monthly basis I get standard file from on of my departments
- I save the file on Google Drive and automatically copy certain information to my Sheets that I use to analyse this information
- I finished the code that does the copy, selection, etc.
I am struggling with the first piece - some sort of SelectBox that I would use to select source file. I can write code that will search Google Drive and display potential files, display them in ListBox, but maybe there is other way (the simpler the better). What would you recommend here?
Google has nice Box that shows up when you try to copy sheet into other Sheets document, but it seems not to be avaialble for Script.
Any help is much appreciated.

Looking to create a Google App Script that duplicates a complicated sheet? Ideas?

In the end, I want to make a script that creates a folder that has other folders in it with a bunch of copies of a custom data sheet our school is using for data analysis.
As of now, I have created a whole system of Google Data Sheets that are connected through the IMPORTRANGE feature of Google sheets that our school uses to compare data. I would like to implement this system in other schools and wanted to try and write a Google App Script to set it up.
I have a couple of questions:
Is it possible to use a script to create a document is automatically set up to use the IMPORTRANGE feature to import data from another document?
If I have a sheet set up already (the standard data sheet we use) that I want to make 400 copies of in different folders, do I have to code the script to generate this document from scratch? Do I code it to pull a copy from somewhere? What do you guys think?
Does this even seem like something that's possible?
Thanks so much for your help guys!
Brandon
Sure. After you create the document, you'll just insert =IMPORTRANGE() using setFormula() or setFormulas(). You will have to manually grant permission for the sheet to import ranges the first time you open it, and any time after when you insert =IMPORTRANGE() with a reference to a new sheet, though.
This is no problem either. You can use the Drive Service and makeCopy() to copy a file into a destination folder you specify.

Use a Google Docs Spreadsheet as a datasource for a dynamic Google Sites webpage

I have a Google Form that feeds a Google Docs Spreadsheet. I'd like to--in turn--have that Google Docs Spreadsheet feed a webpage.
In plainer English, babysitters fill out the form to sign up to be in our community's Babysitter Directory. The spreadsheet houses all of the data. I'd like to code a webpage to pull selected bits of the data for the online directory.
I've tried doing a separate sheet in the spreadsheet, using a QUERY to select the columns that I want to include (and the order in which I want to include them), publishing that sheet to the web, then embedding that sheet into the webpage in an iFrame. And that works.
But even with the QUERY, there are SO many columns that users need to scroll WAY over to the right to see all the data for each babysitter. It's unwieldy.
What would be way better would be if I could break the data for each entry over multiple lines and do some nice formatting for a directory, rather than just a linear spreadsheet. So that, essentially, each babysitter's "entry" in the directory is more than 1 line long. Does that make sense?
If I was working in Office, I would know exactly what to do: use the Excel spreadsheet as the datasource for a Word Mail Merge and I would put move the fields around on the page to make it all look good.
And, to be sure, if I can do this in a Google Doc, then embed the Doc into the webpage, that's fine, too. But I would think there's some way I can do it directly in the Google Site?
Can I?
If anybody has even just a reference page for me to take a look at, I'd appreciate it.
Thanks!
Are you trying to do this in Google Sites? If so, you can embed the entire spreadsheet on the page, but if you only want certain columns, you can try inserting an Apps Script widget on the page.
You need to know how to write a Google Apps Script that will run JS functions and render HTML, here is a tutorial
To create the Script that can run on your page, go to:
More > Manage site > Apps Script > Add new script
Here's also a link to how to interact with Spreadsheet data.
What you want to do is more or less a database interface that uses a spreadsheet as 'data holder', depending on your programming skills it can be quite easy or very hard...
Here is an example of such a webapp, its has probably too many fields and features but the general idea is the same (a quick search tool and a window to show results).
It that what you had in mind ?
If so I can share the code to help you to get started but if you are not familiar with javascript it will probably need too much effort to get through.