Get details of cells changed from a Google Spreadsheet change notification in a machine readable format

前端 未结 1 723
渐次进展
渐次进展 2020-12-17 04:04

If I have a Google Spreadsheet e.g.

https://docs.google.com/spreadsheet/ccc?key=0AjAdgux-AqYvdE01Ni1pSTJuZm5YVkJIbl9hZ21PN2c&usp=sharing

And I have set u

相关标签:
1条回答
  • 2020-12-17 04:46

    You could build a function that checks for changes. One way to do this is by comparing multiple instances of the same spreadsheet. If there are differences, you could email yourself. Using the time driven trigger, you can check every minute, hour, day, or week (depending on your needs).

    var sheet = **whatever**;//The spreadsheet where you will be making changes
    var range = **whatever**;//The range that you will be checking for changes
    var compSheet = **whatever**;//The sheet that you will compare with for changes
    function checkMatch(){
      var myCurrent = sheet.getRange(range).getValues();
      var myComparison = compSheet.getRange(range).getvalues();
      if(myCurrent == myComparison){//Checks to see if there are any differences
        for(i=0;i<compSheet.length;++i){ //Since getValues returns a 'multi-dimensional' array, 2 for loops are used to compare each element
         for(j=0;j<compSheet[i].length;++i){
          if(myCurrent[i][j] != myComparison[i][j]){//Determines if there is a difference;
           //***Whatever you want to do with the differences, put them here***
         }
        }
    
        myEmailer(sheet.getUrl());//Passes the url of sheet to youur emailer function 
        compSheet.getRange(range).setValues(myCurrent);//Updates compSheet so that next time is can check for the next series of changes
        }
      }
    

    Then from Resources>Current project's triggers you can set checkMatch to run every minute.

    Also check out https://developers.google.com/gdata/samples/spreadsheet_sample for pulling data as json

    0 讨论(0)
提交回复
热议问题