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

367
Vistas
How to get TextStyles/Attributes (fontColor, fontFamily, etc.) of a Googlesheet cell in AppScript, then set it in a Table

I have a Script in Googlesheets that is suposed to use the sheet as a modifiable template (colors and font should be modifiable), it copies it and paste it as a Table in GoogleSlides. It copies each cell one by one and then it puts it in the slide table cell. My problem is right now i could only get it to copy the text and background color of each cell, not the fontFamily, nor the fontColor.

This is the relevant part of the code:

var slidesPage = SlidesApp.openById(slideID).getSlides()[slideBegin];
var rows = values.length;
var columns = values[0].length;
var table = slidesPage.insertTable(rows, columns);


for (var r = 0; r < rows; r++) {
  for (var c = 0; c < columns; c++) {
    var cell = table.getCell(r, c);
    cell.getText().setText(values[r][c]);
    cell.getFill().setSolidFill(backgrounds[r][c]);
    var alignment;
    switch(horizontalAlignments[r][c]) {
      case "general-left":
        alignment = SlidesApp.ParagraphAlignment.START;
        break;
      case "general-right":
        alignment = SlidesApp.ParagraphAlignment.END;
        break;
      case "center":
        alignment = SlidesApp.ParagraphAlignment.CENTER;
        break;
    }
    //cell.getText().getParagraphStyle().setParagraphAlignment(alignment);
  }
}

I have tried with .getAttributes or stuff like that, but i cant find how is it supposed to go. I know i probably have to set a "var" with the attributes and then add something like cell.getAttributes().setAttributes() but not sure, im completly stuck.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I know nothing about Slides but in Spreadsheet the thing you want is getRichTextValue() and Class TextStyle

You can get the attributes from a text in a cell about this way:

function myFunction() {
  var ss     = SpreadsheetApp.getActiveSheet();
  var text   = ss.getRange('a1').getRichTextValue() // .getRuns()[0];
  var style  = text.getTextStyle();
  var size   = style.getFontSize()
  var family = style.getFontFamily();
  var color  = style.getForegroundColor();
  var bold   = style.isBold();
  var italic = style.isItalic();
  // etc
  console.log(size, family, bold, italic, color);
}

Update

https://developers.google.com/apps-script/reference/slides/text-range

Surprisingly I see no methods set... in TextRange object in Slides except the setText(text)! There are the get... methods but they're quite useless if you can't apply these attributes.

It looks like this part of Slides App API is not ready yet.

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