Adding Buttons To Google Sheets and Set value to Cells on clicking

前端 未结 3 1119
陌清茗
陌清茗 2020-11-29 08:50

I am new to Google Script.

I have a Google Sheet with 5 columns, on each column I need a button (with text 1,2,3,4,5).

And on each button clic

3条回答
  •  旧巷少年郎
    2020-11-29 08:58

    It is possible to insert an image in a Google Spreadsheet using Google Apps Script. However, the image should have been hosted publicly over internet. At present, it is not possible to insert private images from Google Drive.

    You can use following code to insert an image through script.

      function insertImageOnSpreadsheet() {
      var SPREADSHEET_URL = 'INSERT_SPREADSHEET_URL_HERE';
      // Name of the specific sheet in the spreadsheet.
      var SHEET_NAME = 'INSERT_SHEET_NAME_HERE';
    
      var ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
      var sheet = ss.getSheetByName(SHEET_NAME);
    
      var response = UrlFetchApp.fetch(
          'https://developers.google.com/adwords/scripts/images/reports.png');
      var binaryData = response.getContent();
    
      // Insert the image in cell A1.
      var blob = Utilities.newBlob(binaryData, 'image/png', 'MyImageName');
      sheet.insertImage(blob, 1, 1);
    }
    

    Above example has been copied from this link. Check noogui's reply for details.

    In case you need to insert image from Google Drive, please check this link for current updates.

提交回复
热议问题