如何从Google Apps脚本访问新的“单元格内图片"? [英] How to access new 'in-cell-image' from google apps script?

查看:101
本文介绍了如何从Google Apps脚本访问新的“单元格内图片"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新功能插入">图像">"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.

我已经尝试过类似的事情:

I've tried things like this:

// 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 response,但是不会返回图像数据:

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.

希望对您有帮助!

这篇关于如何从Google Apps脚本访问新的“单元格内图片"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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