Several functions in one

Asked

Viewed 41 times

-3

I have two independent functions that apply spreadsheet formatting to googledocs, and I would like to merge them into one. These are functions 1 and 2 below.

FUNCTION 1

function nomeColunas() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];

  var nomes = [["DATA", "AUDITOR", "MEDIDAS SOLICITADAS",]];

  var faixa = sheet.getRange("A1:I1");
  faixa.setValues(nomes);
}

FUNCTION 2

function formataCelulas() {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheets()[0];
  var faixa = sheet.getRangeList(['A:M']);

  faixa.setHorizontalAlignment('center');
  faixa.setVerticalAlignment('middle');
  faixa.setWrap(true);
  Logger.log(formataCelulas);

}
  • It does not depend on anything not. It is exactly what the colleague answered, which worked.

1 answer

1


Hello! It would be something like that:

function formataPlanilha() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
    var nomes = [["DATA", "AUDITOR", "MEDIDAS SOLICITADAS",]];
    var faixaColNome = sheet.getRange("A1:I1"); // Nome Colunas
    var faixaCelula = sheet.getRangeList(['A:M']); // Formata Celulas

    // Nome Colunas
    faixaColNome.setValues(nomes);

    // Formata Celulas
    faixaCelula.setHorizontalAlignment('center');
    faixaCelula.setVerticalAlignment('middle');
    faixaCelula.setWrap(true);
    Logger.log(formataPlanilha);
}

I hope I’ve been of some help :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.