14

I use sheets.spreadsheets.values.get to get information inside a Spreadsheet, but the cells that contain images show an empty string value.

I tried using values:userEnteredValue as a parameter for the request (as shown in this question Retrieve images in cells using Google Sheets API), but that didn't work.

sheets.spreadsheets.values.get({
      spreadsheetId: 'XXX',
      range: 'firstSheet!A1:E10',
      key: "XXXX"
      //values: 'userEnteredValue'
}

This is what I currently get and have enter image description here


EDIT: I realized one of my problems was that I used spreadsheets.values.get when I should be using spreadsheets.get. I have changed this, but I still cant manage to get the url

enter image description here

The cell that contains text has a userEnteredValue property, but the one that contains the image does not.

7
  • imgur.com/a/aQBcxjn using the fields parameter returns an empty object for the image Commented May 14, 2019 at 20:54
  • From your question, I couldn't understand about your Spreadsheet. In order to correctly understand about your situation, can you provide a sample Spreadsheet and script? Of course, please remove your personal information. Commented May 14, 2019 at 22:05
  • 1
    [@Tanaike], you can place an image in a spreadsheet cell with something like =image("https://www.google.com/images/srpr/logo3w.png"), but sheets.spreadsheets.values.get() returns empty string for that cell. Commented May 14, 2019 at 22:43
  • 1
    @Tanaike, your answer works, I voted up Commented May 15, 2019 at 0:56
  • 1
    Has anyone figured out how to get this to with with images that are inserted and not added with the =image() formula? It still remains blank when using Insert. Commented Jan 16, 2022 at 14:29

1 Answer 1

14
  • You want to retrieve URL from =image("https://www.google.com/images/srpr/logo3w.png") in a cell.
  • You want to use the method of sheets.spreadsheets.values.get().
  • You want to achieve this using googleapis of Node.js.
    • You have already been able to use Sheets API.

If my understanding is correct, how about this modification?

Modification point:

  • =image("https://www.google.com/images/srpr/logo3w.png") is put to a cell as a formula. So in order to retrieve the formula, please use valueRenderOption: "FORMULA".

Modified script:

This modified script supposes that =image("https://www.google.com/images/srpr/logo3w.png") is put in a cell "A1" of a sheet name of "Sheet1".

sheets.spreadsheets.values.get(
  {
    spreadsheetId: "###",
    range: "Sheet1!A1",
    valueRenderOption: "FORMULA"
  },
  function(err, res) {
    if (err) {
      console.log(err);
      return;
    }
    const url = res.data.values[0][0].match(/https?:\/\/[\w\S][^"]+/)[0];
    console.log(url);
  }
);

Result:

https://www.google.com/images/srpr/logo3w.png

Reference:

If I misunderstood your question and that was not the result you want, I apologize.

Edit:

  • You want to retrieve the URL of image which inserted in a cell and on a sheet by "the INSERT option in spreadsheet".

If my understanding is correct, unfortunately, in the current stage, when an image is inserted in a cell from an URL by "the INSERT option in spreadsheet", the URL of image cannot be retrieved by Sheets API and Spreadsheet Service. Also when an image is inserted on a sheet from an URL by "the INSERT option in spreadsheet", the URL of image cannot be retrieved by Sheets API and Spreadsheet Service. I apologize for this situation.

Reference:

Sign up to request clarification or add additional context in comments.

4 Comments

this works great using the =image() formula but is it possible to get the url of an image uploaded using the INSERT option in spreadsheet? when i do this the image is shown on the cell but the formula is empty
@Bruno Puccio Thank you for replying. I updated my answer. Could you please confirm it? If I misunderstood your question, please tell me.
Has anyone figured out how to get this to with with images that are inserted and not added with the =image() formula? It still remains blank when using Insert.
@Mr. BigglesWorth About your question of Has anyone figured out how to get this to with with images that are inserted and not added with the =image() formula? It still remains blank when using Insert., I would like to support you. But I cannot correctly imagine your question. So can you post it as a new question with detailed information? By this, it will help users including me think of the solution. If you can cooperate to resolve your question, I'm glad. Can you cooperate to do it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.