简体   繁体   English

如何通过Python脚本在数据Feed上触发Google电子表格脚本?

[英]How to trigger google spreadsheet script on data feed from Python script?

My Python app feeds data into the sheet. 我的Python应用程序将数据输入到工作表中。 I want incoming data to trigger the script. 我希望传入的数据触发脚本。

On spreadsheet side, there is onEdit script, but not triggered by coming inputs. 在电子表格方面,有onEdit脚本,但不会被后续输入触发。 I've also set trigger on form submit in trigger manager, also doesn't work. 我还在触发器管理器中的表单提交上设置了触发器,也不起作用。 Any help, how it should be done? 有什么帮助,应该怎么做?

Thanks 谢谢

It does not work. 这是行不通的。 I've installed the onChange trigger with: 我已经安装了onChange触发器:

function createSpreadsheetChangeTrigger() {
    var ss = SpreadsheetApp.getActive();
    ScriptApp.newTrigger('onChange')
      .forSpreadsheet(ss)
      .onChange()
      .create();
    } 

I can see it in triggers manager. 我可以在触发器管理器中看到它。 Python adds row and the script is not fired. Python将添加行,并且不会触发脚本。 Only manual edit triggers the script, below: 仅手动编辑会触发脚本,如下所示:

function onChange(e) {
  var sheet = e.source.getActiveSheet();
  mit = sheet.getRange(1,12).getValue();
  mat = sheet.getRange(1,13).getValue();
  mih = sheet.getRange(1,14).getValue();
  mah = sheet.getRange(1,15).getValue();
  var chart = sheet.getCharts()[0];
  chart = chart.modify()
    .setOption('vAxes.0.viewWindow.max', mat)
    .setOption('vAxes.0.viewWindow.min', mit)
    .build();
  sheet.updateChart(chart);
  var chart1 = sheet.getCharts()[1];
  chart1 = chart1.modify()
    .setOption('vAxes.0.viewWindow.max', mah)
    .setOption('vAxes.0.viewWindow.min', mih)
    .build();
  sheet.updateChart(chart1);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM