Google Spreadsheet Scripts Common to Spreadsheets (Not Libraries)

I did a ton of searching for this problem, and I think the problem is that all the answers lead to a solution that requires creating a library. Then the only way to add this library to the spreadsheet is to create a new script for this table and enable it.

What I want: A bunch of spreadsheets in which everyone includes one script wizard. Each time the script is updated, they are all updated to use the latest script.

What I have: 15 spreadsheets that have copies of the original script. The original script has changed, and now it seems to me that I need to change every script called Copy of myScriptNamethat exists in every copied spreadsheet.

What I did: I created the first table and wrote a script from a project created in its script editor. Worked great. Then I made 14 copies of this table for each division of the company to use.

How can I just share the script and manage it outside of any of the individual spreadsheets? I need to miss something, considering all the people who are looking for the same answer. I just don't see how the library library solves my use case.

Thank!

I don’t see that this will help, but in the comment request there is a script here:

function createRollupTable() {

  //Return if:
  //   There is only the account code parameters passed in with no quarterly info
  //   If the length of the account code parameters passed is empty
  if(arguments.length <= 1 || !arguments[0] || arguments[0].length <= 0) {
    return "";
  }

  var rollupTable = new Array();
  var fullListAccountCodes = arguments[0];

  //The first column of output is the full list of account codes for all the quarters
  rollupTable[0] = fullListAccountCodes;

  //Array to keep the YTD total for each account code
  var yearlyAccountCostOutput = new Array(fullListAccountCodes.length);

  //Iterate over all the quarters that were passed in
  for(var i=1;i<arguments.length;i++) {

    //This array should be set to the total length of the available account codes
    var quarterlyRollupCostOutput = new Array(fullListAccountCodes.length);
    var quarterlyBreakdown = arguments[i];
    var quarterIndexCounter = 0;
    var quarterTotalCost = 0;

    //Iterate over all the account codes
    for(var j=0;j<fullListAccountCodes.length && quarterIndexCounter<quarterlyBreakdown.length;j++) {

      //Find the one that matches the current account code for this quarter
      if(fullListAccountCodes[j] == quarterlyBreakdown[quarterIndexCounter][0]) {

        //Set the index of the output based on the full list so they align
        quarterlyRollupCostOutput[j] = quarterlyBreakdown[quarterIndexCounter][1];

        //Add this cost to the running total for the quarter
        quarterTotalCost += quarterlyBreakdown[quarterIndexCounter][1];

        //Add the total amount for the yearly rollup for that account code
        if(yearlyAccountCostOutput[j]) {
          yearlyAccountCostOutput[j] += quarterlyBreakdown[quarterIndexCounter][1];
        } else {
          yearlyAccountCostOutput[j] = quarterlyBreakdown[quarterIndexCounter][1];
        }

        //Increment the counter so we search for the next account code in the quarter
        quarterIndexCounter++;

      }
    }

    rollupTable[i] = quarterlyRollupCostOutput;

    //Add a blank row in the results for spacing
    rollupTable[i].push("");

    //Add the quarterly total cost
    rollupTable[i].push(quarterTotalCost);

  }

  //Add a blank row for spacing
  rollupTable[0].push("");

  //Google spreadsheet forces you to pad with non breaking spaces, no right align option available
  var spaces = "";
  var numSpaces = 66;
  for(var i=0;i<numSpaces;i++){spaces+=String.fromCharCode(160);};

  //Add a row for the Totals
  rollupTable[0].push(spaces + "Totals:");

  //Add the YTD column
  rollupTable.push(yearlyAccountCostOutput);

  return rollupTable;
}
+5
source share
1 answer

, , , , master script, , , , , ...

, , , - script

, script , . , .

script. , / script.

, : 1 script, 1 template, script, master, , .

, , dev. script ( ). , script. , dev, ( , ).

- script, . , - .

[: 3/15/2015] , - Chrome //, , , OP. Google, .

https://developers.google.com/apps-script/add-ons/

+5

All Articles