如何从谷歌应用程序脚本访问新的“in-cell-image"? [英] How to access new 'in-cell-image' from google apps script?

查看:22
本文介绍了如何从谷歌应用程序脚本访问新的“in-cell-image"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google 表格中的新函数插入 > 图像 > 单元格中的图像将图像插入单元格中,而不是作为 OverGridImage.我想以这种方式插入图像,然后从 Google Apps 脚本访问图像.这可能吗?

The new function Insert > Image > Image in Cell in Google sheets inserts an image in a cell and not as an OverGridImage. I would like to insert the image in this manner and then access the image from Google Apps Script. Is this possible?

插入图片后,选中单元格时,单元格的公式为空.我尝试搜索 GAS 参考资料,但找不到有关此相对较新功能的任何信息.有关于过度网格图像的信息.我希望内嵌图像具有类似的功能.

After inserting the image the formula of the cell is blank when the cell is selected. I tried searching the GAS reference, but I could not find any information on this relatively new feature. There is information on the over grid images. I would expect the in-cell image to have similar functions.

我尝试过这样的事情:

// See what information is available on a cell with inserted image:
var image = sheet.getRange(1, 1).getFormula();
Logger.log(image);

日志显示为空.我尝试了几个:.getImage()(不存在)、.getValue()、.getFormula()

The logs shows up empty. I tried several: .getImage() (does not exist), .getValue(), .getFormula()

我希望能够以某种方式访问​​图像 URL 或 Blob.

I would expect to be able to access the image URL or Blob in some way.

推荐答案

答案:

这是一项新功能,不幸的是,目前还没有一种方法可以使用 Google Apps 脚本或 Sheets API 以这种方式将图像插入到单元格中.

尝试使用带有以下参数的 spreadsheets.get 方法获取单元格中的数据

Attempting to get the data in a cell using the spreadsheets.get method with the following parameters

  spreadsheetId: "ID of private spreadsheet created in Drive"
  includeGridData: True
  ranges: D7
  fields: sheets/data/rowData/values

将返回 200 响应,但不返回图像数据:

Will return a 200 response, however the image data is not returned:

{
  "sheets": [
    {
      "data": [
        {
          "rowData": [
            {
              "values": [
                {
                  "userEnteredValue": {},
                  "effectiveValue": {},
                  "effectiveFormat": {
                    "backgroundColor": {
                      "red": 1,
                      "green": 1,
                      "blue": 1
                    },
                    "padding": {
                      "top": 2,
                      "right": 3,
                      "bottom": 2,
                      "left": 3
                    },
                    "horizontalAlignment": "LEFT",
                    "verticalAlignment": "BOTTOM",
                    "wrapStrategy": "OVERFLOW_CELL",
                    "textFormat": {
                      "foregroundColor": {},
                      "fontFamily": "Arial",
                      "fontSize": 10,
                      "bold": false,
                      "italic": false,
                      "strikethrough": false,
                      "underline": false
                    },
                    "hyperlinkDisplayType": "PLAIN_TEXT"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

功能请求:

但是,在 Google 的问题跟踪器上有一个功能请求,您可以在此处找到.如果您转到功能请求页面并点击左上角的星标,您可以让 Google 知道您也喜欢此功能,并且会自动获取有关其进度的更新.

Feature Request:

There is however a Feature request for this on Google’s Issue Tracker which you can find here. If you head over to the feature request page and click the star in the top left, you can let Google know that you also would like this feature, and will automatically get updates about its progress.

这篇关于如何从谷歌应用程序脚本访问新的“in-cell-image"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆