Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
How do you add 0.1 to a setvalue?

I have a variable ekeys, which basically creates a ruler down a page and sets a depth (elevation) value down the ruler compared to the 0 value.

i.e. the ruler will show 1 metre depth. If surface elevation is set to 4.2 metres, then 1 metre down the corresponding elevation will be 4.2 metres minus 1 metre - which = 3.2 metres. For some reason it is 0.1 m out (i.e. showing 3.1 metres instead of 3.2 metres).

Is there an easy way to change this code: setValue(eKeys[k])

to add 0.1?

i.e. .setValue(eKeys[k]+0.1) <--- this does not work (it shows a value of 30.2 instead of 3.2).

var rKeys = Object.keys(mergeThisRows);
  var eKeys = Object.keys(mergeThisRowsE);
  for (k = 0; k < rKeys.length; k++) {
    shTemplate.getRange(mergeThisRows[rKeys[k]] + STARTT_ROW - 1, DEPTH_COL + 1, 2, 1).breakApart().merge().setValue(rKeys[k]).setFontColor("black").setFontSize(6).setVerticalAlignment("top").setHorizontalAlignment("right");
    shTemplate.getRange(mergeThisRows[rKeys[k]] + STARTT_ROW - 1, DEPTH_COL + 1, 2, 1).setBorder(true, null, null, null, null, null, '#000000', SpreadsheetApp.BorderStyle.SOLID);;
    if (eKeys[k] != undefined) {
      shTemplate.getRange(mergeThisRowsE[eKeys[k]] + STARTT_ROW - 1, ELEVATION_COL + 1, 2, 1).breakApart().merge().setValue(eKeys[k]).setNumberFormat("0.0").setFontColor("black").setFontSize(6).setVerticalAlignment("top").setHorizontalAlignment("right");
      shTemplate.getRange(mergeThisRowsE[eKeys[k]] + STARTT_ROW - 1, ELEVATION_COL + 1, 2, 1).setBorder(true, null, null, null, null, null, '#000000', SpreadsheetApp.BorderStyle.SOLID);
    }
  }
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I'd propose to use the unary + operator to convert the string into a number:

setValue(+eKeys[k] + 0.2)

Reference

  • Unary plus (+)
about 4 years ago · Juan Pablo Isaza Denunciar

0

setValue(parseInt(eKeys[k])+0.2)
-> 3.2
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda