1

tengo este código funcionando (copio solo una parte)

var valores = [[FACTURA.getRange(CELDA_NRO_FACTURA).getValue(),  //Nro Factura
                 FACTURA.getRange(CELDA_FECHA).getValue(),   //Fecha
                 FACTURA.getRange(CELDA_MEDIO_PAGO1).getValue(),   //Medio de pago
                 FACTURA.getRange(CELDA_DTO_RGO_GENERAL).getValue(),   //Dto/Rgo general
            
            //Fila 6
             FACTURA.getRange(PRIMERA_FILA,PRIMERA_COLUMNA).getValue(),  //Código
             FACTURA.getRange(PRIMERA_FILA,PRIMERA_COLUMNA + 1).getValue(),  //Cantidad
             FACTURA.getRange(PRIMERA_FILA,PRIMERA_COLUMNA + 2).getValue(),  //Descripción
             FACTURA.getRange(PRIMERA_FILA,PRIMERA_COLUMNA + 7).getValue(),  //Unitario
             FACTURA.getRange(PRIMERA_FILA,PRIMERA_COLUMNA + 8).getValue(),  //Dto/Rgo x fila

            //Fila 7
             FACTURA.getRange(PRIMERA_FILA + 1,PRIMERA_COLUMNA).getValue(),  //Código
             FACTURA.getRange(PRIMERA_FILA + 1,PRIMERA_COLUMNA + 1).getValue(),  //Cantidad
             FACTURA.getRange(PRIMERA_FILA + 1,PRIMERA_COLUMNA + 2).getValue(),  //Descripción
             FACTURA.getRange(PRIMERA_FILA + 1,PRIMERA_COLUMNA + 7).getValue(),  //Unitario
             FACTURA.getRange(PRIMERA_FILA + 1,PRIMERA_COLUMNA + 8).getValue(),  //Dto/Rgo x fila


            //Fila 8
             FACTURA.getRange(PRIMERA_FILA + 2,PRIMERA_COLUMNA).getValue(),  //Código
             FACTURA.getRange(PRIMERA_FILA + 2,PRIMERA_COLUMNA + 1).getValue(),  //Cantidad
             FACTURA.getRange(PRIMERA_FILA + 2,PRIMERA_COLUMNA + 2).getValue(),  //Descripción
             FACTURA.getRange(PRIMERA_FILA + 2,PRIMERA_COLUMNA + 7).getValue(),  //Unitario
             FACTURA.getRange(PRIMERA_FILA + 2,PRIMERA_COLUMNA + 8).getValue(),  //Dto/Rgo x fila

            //Fila 9
             FACTURA.getRange(PRIMERA_FILA + 3,PRIMERA_COLUMNA).getValue(),  //Código
             FACTURA.getRange(PRIMERA_FILA + 3,PRIMERA_COLUMNA + 1).getValue(),  //Cantidad
             FACTURA.getRange(PRIMERA_FILA + 3,PRIMERA_COLUMNA + 2).getValue(),  //Descripción
             FACTURA.getRange(PRIMERA_FILA + 3,PRIMERA_COLUMNA + 7).getValue(),  //Unitario
             FACTURA.getRange(PRIMERA_FILA + 3,PRIMERA_COLUMNA + 8).getValue(),  //Dto/Rgo x 
             ]];

datos.getRange(datos.getLastRow()+1,1,1,valores.length).setValues(valores);

y quisiera remplazarlo con este otro

var valores = [factura.getRange(CELDA_NRO_FACTURA).getValue(),  //Nro Factura
                 factura.getRange(CELDA_FECHA).getValue(),   //Fecha
                 factura.getRange(CELDA_MEDIO_PAGO1).getValue(),   //Medio de pago
                 factura.getRange(CELDA_DTO_RGO_GENERAL).getValue(),   //Dto/Rgo general
                 factura.getRange(CELDA_OBSERVACIONES).getValue()]  //Observaciones
  
  Logger.log(valores)

  const COLUMNA_CODIGO = 3
  const COLUMNA_CANTIDAD = 4
  const COLUMNA_DESCRIPCION = 5
  const COLUMNA_UNITARIO = 10
  const COLUMNA_DTO_RGO = 11
  const CANT_FILAS_FACTURA = 10
  var cont = 5
  
  for(fila=0;fila < CANT_FILAS_FACTURA; fila++){
    valores.push(factura.getRange(PRIMERA_FILA + fila,COLUMNA_CODIGO).getValue())  //Código
    valores.push(factura.getRange(PRIMERA_FILA + fila,COLUMNA_CANTIDAD).getValue())  //Cantidad
    valores.push(factura.getRange(PRIMERA_FILA + fila,COLUMNA_DESCRIPCION).getValue())  //Descripción
    valores.push(factura.getRange(PRIMERA_FILA + fila,COLUMNA_UNITARIO).getValue())  //Unitario
    valores.push(factura.getRange(PRIMERA_FILA + fila,COLUMNA_DTO_RGO).getValue())  //Dto/Rgo x fila
  }

  Logger.log(valores)
  datos.getRange(datos.getLastRow()+1,1,1,valores.length).setValues(valores); 

Mi problema es que soy principiante y no se como asignarle los valores a la variable "valores" en el for. Creo que se agregan con push, pero cuando lo ejecuto me da el siguiente error: Exception: The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues.

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.