Copying the Linkage of Google Sheets and Google Slides - google-chrome

I have a Google Slide where all the charts are generated via a linked Google Sheet. I am trying to find a way of duplicating this Original Slide/Sheet to a new 'instance' - whereby the new 'instance' allows me to independently edit the New Google Sheet and it update the New Google Slide.
I tried to edit the linked object source within the New Slide but this does not seem to be possible. I cannot find a way to edit the New Google Slide and link charts to a different spreadsheet
edit the individual charts and link them to a new spreadsheet/data source.
I have also tried copying both files (Slide + Sheet), placing both files in a folder and duplicating the entire folder. However the Slide in the 'Copy' simply links to the original Sheet.
Currently, it looks like I have to delete all the charts in the New (duplicated) Slide and then re-add them by inserting new charts. This would be very time consuming - not only do they have to be re-added, but they need to be re-sized, re-positioned and the order re-arranged (so we can easily edit certain text/graphics that sit above them).

Related

Can a spreadsheet (with format an everything) , be attached to a sidebar of another spreadsheet?

I'm creating a calendario asignacion Tools that works with sheets.
I have already make it work but I want to know if it is possible to attach a whole spreadsheets into a sidebar of the spreadsheets of the assignation tool.

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.

Pull/parse info from HTML into Google Sheet using XPath

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!

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.

What is the right way to put a Drive image into a Sheets cell programmatically?

I have a WebApp that collects work site data into a Google Sheets spreadsheet and also collects work site photos into a Google Drive folder that I create for each job. Some, but not all, of the photos must be viewable in a cell in Google Sheets, such that the sheet can be printed as part of a job completion report.
I use Google Picker to upload files to the folder specific to the work site job. I am unsure of the best way to use them from there.
I have had success setting a cell formula such as =IMAGE("hllp://i.imgur.com/yuRheros.png", 4, 387, 422), but only with images pulled from elsewhere on the web.
Using the permalink trick like this =IMAGE("hllp://drive.google.com/uc?export=view&id=0B8xy-TdDgbjiFoOldUlLT091NXM", 4, 387, 422) does not work; I think it won't tolerate the URL redirect that Google does on those links.
The other way I have read about, but not tried yet, is to write the actual blob into the cell. However, I suspect I will lose any control over subsequent formatting of the report.
Perhaps I am going to need to record the image specification in several ways in several cells:
its Google Drive hash key
its dimensions
its alternate location in imgur.com (or similar)
its blob
Is there a programmatic way to get Google's redirected final URL for an image, equivalent to opening the image and copying the URL by hand? Could one trust it for ever, or does it change over time?
Update : I am wrong about =IMAGE("hllp://drive.google.com/uc?export=view&id=0B8xy-TdDgbjiFoOldUlLT091NXM", 4, 387, 422) not working. It is essential that the image be shared to "anyone with the link", even if the owner of the spreadsheet is also the owner of the image.
I am going to go with recording just 1.hash key and 2.dimensions as my solution, but I'd be delighted to know if anyone else has a better idea.
Assuming you get the ID of your image in your drive, you can use a code like below to insert an image in the last row of a sheet (the url is a bit different than usual):
...
var img = DriveApp.getFileById('image ID');// or any other way to get the image object
var imageInsert = sheet.getRange(lastRow+1, 5).setFormula('=image("https://drive.google.com/uc?export=view&id='+img.getId()+'")');// in this example the image is in column E
sheet.setRowHeight(lastRow+1, 80);// define a row height to determine the size of the image in the cell
...
I would suggest that you carefully check the sharing properties of the files you are trying to show : they must be set to "public" of moved in a folder that is also "publicly shared"
I made a two lines script to use the share link of an image in Google Drive.
Go to Tools > Script editor.
Copy, paste the following code
Save
function DRIVE_IMAGE(link){
return link.replace("open?", "uc?export=download&");
}
Using the script :
Copy the Get shareable link of your image in Google Drive (Maybe you need to set the share preference to Public on the web).
Go to a Google sheets cell.
Enter the formula
=IMAGE(DRIVE_IMAGE("COPIED_LINK"))
We build a lot of sheets with images and use the static link available in the google album archive { https://get.google.com/albumarchive/... } rather than the dynamic link in google photos. the link in the archive normally ends in "-rw" which limits view-ability to some with whom the doc is shared with. Deleting "-rw" from the end of the link seems to help.