Pull/parse info from HTML into Google Sheet using XPath - html

I'm currently trying to make a first script in Google Sheets to automate a small task in the workplace.
The plan is to have the sheet make a call to a specific URL by combining the page url and a tracking number, e.g. https://t.17track.net/en#nums=NUM123ABC
Then pull relevant data from a specific div relevant to the tracking information box in the result, and fire it back into a cell or cells in Google Sheets.
My question is, can this be done by using XPath on an HTML page such as the one above?
Thanks for your time!

Related

App Script authorizations associated with Google Sheets

I have managed to incorporate an app into a Google sheet I was able to copy from a tutorial video. The app provides a Custom Menu in the sheet that allows a user to conduct a search of content across the sheet.
The sheet, with editor access and Custom Menu showing, is available here:
https://docs.google.com/spreadsheets/d/1fl2B9yrZA75Vm5KwVsLsZ4K2_GUYO35LQLYxDcSoauY/edit?usp=share_link
and it works fine even if I may do some more formatting.
The sheet is available via the Search Test button near bottom right on this page:
https://www.victoriasforestryheritage.org.au/resources/records.html
but, as you will see, I am unable to set authorizations in the back end so that any user on the front end can access the sheet with the custom menu showing so they can search the data. The link above shows the sheet, but without the Custom Menu.(The custom Menu appears to work if I prove Editor access, but obviously I do not wish to do that)
The use of Apps Script is totally new to me, and I have searched widely for help, but obviously have found no solution. I read what I think are the relevant Google documents but I simply do not have the depth of understanding to interpret them.
In summary, I wish any user of the website to be able to access a linked google sheet and be able to search that sheet using the Apps Script created Custom Menu .
I am functional with HTML and CSS and just beginning to try and learn some JavaScript. In other words you are corresponding with a relative novice.
I have tried different file access levels as indicated above, I have looked through Apps Script authorization process but frankly I have trouble understanding how and where the Script links to the sheet.
Any help would be much appreciated.
Richard

Google Slides & Apps Script: Unlink all embedded sheet charts

I'm publishing Google Slides containing a lot of embedded charts coming from a Spreadsheet.
I would like to unlink the embedded charts (and thus avoid to get the update button when the data are updated in the spreadsheet).
If google proposes to update all elements at once through the "Linked objects" entry of the Tools menu, there is no option to unlink all in one shot. I would need to go on each chart and select unlink.
So I'm looking now the option of writing a Google Apps Script to do that without success.
I found a similar question on stackoverflow here:
Remove all hyperlinks of a Google Slide using GAS
But the removeLink function does not have any effect on my chart. I still see the chained icon on the top right corner.
Any idea ?
Unfortunately, it seems that in the current stage, there are no methods for directly removing the link to Spreadsheet from Speadsheet. But when the link to Spreadsheet from Speadsheet chart is removed, it is found that the object becomes an image. I thought that this might be used for achieving your goal. So, from this situation, as a workaround, I would like to propose the following sample script.
Sample script:
This sample script converts the Spreadsheet chart to an image on the 1st slide. By this flow, the link to Spreadsheet from Speadsheet chart is removed.
const slide = SlidesApp.getActivePresentation().getSlides()[0];
const charts = slide.getSheetsCharts();
const chart = charts[0];
slide.insertImage(chart.asImage().getBlob(), chart.getLeft(), chart.getTop(), chart.getWidth(), chart.getHeight());
chart.remove();
The flow of this script is as follows.
Retrieve the Spreadsheet chart.
Retrieve the image blob from the chart.
Insert the image blob by copying the size and place of the Spreadsheet chart.
Remove the Spreadsheet chart.
Note:
This sample script copies the size and place. When you want to copy other values, please modify the script.
References:
asImage()
insertImage(blobSource, left, top, width, height)
remove()
Added:
About your additional question as follows.
I think this is a good workaround for charts (such as pie charts, column ... that can be converted as images). Nevertheless, I have some slides where I have some cells embedded. Running this code on this element is displaying an issue. Do you think this also feasible on embedded tables?
The chart is different from the table. So in this case, I think that your additional question is new question.
Your initial question is for removing the Spreadsheet link from the chart. My answer is for your this question. In this case, the table cannot be used. And, in the current stage, unfortunately, there are no methods for removing the link of Spreadsheet from the table. And also, when the Spreadsheet link is removed from the table, the object type is not changed from the table. By this, my workaround cannot be used. But Slides service and Slides API are growing now. So I think that such method might be added in the future update.
So, as the current method, how about reporting your new question to Google issue tracker? By this, the addition of such method might be considered.

is there a way to make a google form response be formatted and sorted on a sheet with multiple pages

I have a google form that sends responses to a google sheet, I want to be able to populate different pages in the sheet depending on a selection from a drop-down menu in the form.
I would also like to format it differently than how the form automatically populates the sheet if this is possible
I have looked for some proper documentation on how to do this but it's hard to find for me, I have tried a sheets formula but this did not work and using google apps script is hard for me since I have no understanding of how it works properly.
=FILTER('Form Responses '!A2:Z,'Form Responses '!B2:B="topic")
=QUERY('Form Responses '!A2:Z,"where B='topic'")
this gives me the no matches are found in filter evaluation error
=query('Form Responses'!A2:H,"Select * Where B='topic'")
Adding this to the seperate pages fixed my problem with the filtering and using templates lets me keep the formatting i wanted, thanks cooper!

How to save image added in a Google Sheet cell to Google Drive?

I have a google sheet that is to be used by a third person.
The sheet contains a column that requires them to upload an image into the cell (using Google Sheets Image In Cell feature).
I want to be able to via Google Apps Script, save these images, with an appropriate name based on a value in the row, to a folder in my Google Drive.
Is this possible?
As #Tanaike said, there is currently no way to do that automatically unless you get the URL and doesnt work on generated images (like QR codes) either. Not even right click works for such.
Externally, the only solution for the moment would be to manually get a screen capture (the 'recortes' tool in Windows can help). To automate this you could do a script to move the browser, then take a capture and save it, then move the browser again, rinse and repeat , but still there is no direct solution inside Google Sheets.

Google sheet cell value to html page

I'm doing a little project and I would like to display the top player (Cell A2) of a ranking (sheet: ranking) in an HTML page. My google sheet is shared with everyone.
I found similar questions with several answers. But it seems that each answer is a part of the cake. I can't manage to take everything and simply apply it to my project.
I'm trying to :
Use the Code.gs file of my google spreadsheet project to return the cell value
Call the cell value in my index.html file using the thing
Display the cell value in a paragraph (p)
What is the easiest way to do that?
Thank you for helping me to find my full cake :)