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

182
Views
Cómo establecer el resultado en 2 decimales en el script de aplicaciones de Google

Tengo el siguiente código y requiero que los resultados tengan 2 decimales

 function TotalVat() { const ss = SpreadsheetApp.openById('1BAj2E_xv3bz_Fnt0Xcm5UidGapZhVWeJ6gA5w3-Vnsj'); const sh = ss.getSheetByName("JOBS"); const vs = sh.getRange(2, 1, sh.getLastRow() - 2, sh.getLastColumn()).getValues(); vs.forEach((r,i) => { sh.getRange(i + 2,38).setNumberFormat("0.#0").setValue(r[35] * (r[36]/100)); }); }

El formato en la hoja de cálculo es de 2 decimales, sin embargo, también estoy enviando el resultado por correo electrónico y aquí el resultado del cálculo tiene más de 2 decimales. Cualquier ayuda será muy apreciada. Gracias

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

0

Probar:

sh.getRange(i + 2,38).setValue(r[35] * (r[36]/100).setNumberFormat("0.00")

about 4 years ago · Juan Pablo Isaza Report

0

Esto funciona para mí:

 function TotalVat() { const ss = SpreadsheetApp.getActive(); const sh = ss.getSheetByName("Sheet0"); const vs = sh.getRange(2, 1, sh.getLastRow() - 1, sh.getLastColumn()).getValues(); vs.forEach((r, i) => { sh.getRange(i + 2, 3).setValue(r[0] * (r[1] / 100)).setNumberFormat("0.00"); }); } 
COL1 COL2
3 10 0.30
9 8 0.72
5 15 0.75
11 12 1.32
0 13 0.00
0 19 0.00
7 15 1.05
18 17 3.06
18 1 0.18
11 17 1.87
9 15 1.35
3 3 0.09
17 dieciséis 2.72
2 4 0.08
3 13 0.39
3 8 0.24
19 1 0.19
19 5 0,95
2 8 0.16
15 10 1.50
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!