Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
Create a comment | Google-SpreadSheet | nodeJS

I am trying to put a comment using NODEJS and the "Google Spread-Sheet" module, I have managed to write in cells, read, delete, but I can not put a comment in a cell, and the tutorials I see only teach discontinued forms, someone could help me? thank you very much.

const { GoogleSpreadsheet } = require('google-spreadsheet');
const creds = require('./googleSheetCredentials.json');

async function accessSpreadSheet() {
    const doc = new GoogleSpreadsheet('XXXXXXXXXXXX');
    await doc.useServiceAccountAuth(creds);
    await doc.loadInfo();
    const sheet = doc.sheetsByIndex[0];

    await sheet.addRow({
        Login: 'hello world', // column A
        Date: '2020-01-01' // column B
    });

    const row = await sheet.getRows();
    console.log(row);

    //await sheet.addComment('2', 'Login', 'Hello world'); Doesn't work 
}

accessSpreadSheet();

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I believe your goal is as follows.

  • You want to insert a note to a cell.
    • From your showing script and await sheet.addComment('2', 'Login', 'Hello world');, I guessed that you wanted to insert a note to the column "A" of the added row.
  • You want to achieve this using node-google-spreadsheet.

In this case, how about the following modification?

Modified script:

const { GoogleSpreadsheet } = require('google-spreadsheet');
const creds = require('./googleSheetCredentials.json');

async function accessSpreadSheet() {
  const doc = new GoogleSpreadsheet('XXXXXXXXXXXX');
  await doc.useServiceAccountAuth(creds);
  await doc.loadInfo();
  const sheet = doc.sheetsByIndex[0];

  // I modified below script.
  const res = await sheet.addRow({
    Login: "hello world", // column A
    Date: "2020-01-01", // column B
  });
  await sheet.loadCells();
  sheet.getCellByA1("A" + res.rowIndex).note = "sample note";
  await sheet.saveUpdatedCells();
}

accessSpreadSheet();
  • When you run this script, a note of sample note is inserted into the column "A" of the added row.

Note:

  • This modified script supposes that you have already been able to get and put values to Google Spreadsheet using Sheets API with google-spreadsheet and your script of await sheet.addRow works. Please be careful about this.

Reference:

  • node-google-spreadsheet
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda