Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
La alerta de Google Apps Script no funciona como se esperaba
function FindLastRowAndDate() { var ss = SpreadsheetApp.getActive().getSheetByName('Math'); ss.activate(); var LastRow = ss.getDataRange().getNumRows(); var Date = SpreadsheetApp.getActiveSheet().getRange(LastRow, 1).getValue(); SpreadsheetApp.getUi().alert("The Value for LastRow is ", LastRow, SpreadsheetApp.getUi().ButtonSet.OK); SpreadsheetApp.getUi().alert("The Value for Date is ", Date, SpreadsheetApp.getUi().ButtonSet.OK); }

La primera alerta funciona bien, excepto que muestra 11.0 en lugar de 11 (como lo hace una alerta simple sin el título). ¿Alguna idea de por qué? La segunda alerta falla por excepción: los parámetros (String,(class),ButtonSet) no coinciden con la firma del método para Ui.alert. Por qué; su sintaxis me parece idéntica? Cualquier pista/solución recibida con gratitud.

Intenté usar const en lugar de var, pero eso no hizo ninguna diferencia

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Descripción

Aparentemente, una alerta Ui no puede tomar un objeto Fecha. Necesita .toString() o usar Utilties.formatDate() para presentar el valor de la fecha.

Para eliminar los dígitos decimales adicionales, use .toFixed() .

Tenga en cuenta que es costumbre tener la primera letra en minúsculas en los nombres de variables y funciones. La primera letra mayúscula se usa normalmente para la clase de objeto o las variables globales.

Guion

 function findLastRowAndDate() { var ss = SpreadsheetApp.getActive().getSheetByName('Math'); ss.activate(); var lastRow = ss.getDataRange().getNumRows(); var myDate = SpreadsheetApp.getActiveSheet().getRange(LastRow, 1).getValue(); SpreadsheetApp.getUi().alert("The Value for LastRow is ", lastRow.toFixed(), SpreadsheetApp.getUi().ButtonSet.OK); SpreadsheetApp.getUi().alert("The Value for Date is ", myDate.toString(), SpreadsheetApp.getUi().ButtonSet.OK); }

Referencia

  • Número.aFijo()
  • Fecha.toString()
  • Utilidades.formatDate()
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!