Scripts de hojas de cálculo de Google compartidos en hojas de cálculo (no bibliotecas)

He hecho un montón de búsquedas para este problema y creo que el problema es que todas las respuestas dan como resultado una solución que requiere que usted cree una biblioteca. Entonces, la única manera que veo para agregar esa biblioteca a una hoja de cálculo es crear un nuevo script para esa hoja de cálculo e incluirlo.

Lo que quiero: un montón de hojas de cálculo que incluyen un script maestro. Cada vez que se actualiza el script, todos se actualizan para usar el último script.

Lo que tengo: 15 hojas de cálculo que tienen copias del script original. El script original ha cambiado y ahora parece que debo editar cada script llamadoCopy of myScriptName que existe dentro de cada hoja de cálculo copiada.

Lo que hice: creé la primera hoja de cálculo y escribí el guión desde un proyecto que creé en su editor de guiones. Funcionó perfecto. Luego hice 14 copias de esa hoja de cálculo para cada división de una empresa para usar.

¿Cómo puedo compartir el script y administrarlo fuera de cualquiera de las hojas de cálculo individuales? Debo estar perdiendo algo aquí, considerando a todas las personas que buscan la misma respuesta. Simplemente no veo cómo hacerlo una biblioteca resuelve mi caso de uso.

¡Gracias!

No veo lo que esto ayudará, pero de acuerdo con la solicitud del comentario, aquí está el script:

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;
}

Respuestas a la pregunta(1)

Su respuesta a la pregunta