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

252
Visualizações
How should I insert one more column in excel in javascript?

I have to put file sizes(need to capture from UI) near to file name(contained in excel) but was finding it difficult to insert such entry and so I created another sheet and class named FileProperties with filePath and fileSize. Then I had put the entries as JSON into new worksheet, then I want to delete the old sheet containing just the file names and want to rename the existing sheet so that it appears same. But when I used rename() and delete() on worksheet level I got an error and the work is more tedious then if I can write the file sizes near to file name in the old sheet.

FileProperties class

export class FileProperties {
    filePath;
    fileSize;
}

Below are the initialization and initially InputSheet is empty and Input_Data is holding File paths under File Path heading

  inputWorksheet = workbook.Sheets.InputSheet;
  oldInputSheet = workbook.Sheets.Input_Data;
  const temp = XLSXReader.utils.sheet_to_json(oldInputSheet);
  temp.forEach((res) => {
    data.push(res);
  });

Below is the code which I was trying to get the entries in new sheet which worked successfully.

      allDataEle = await page.waitForSelector (
        "locator passed here"
      );
      
      fileSize = await page.evaluate((el) => el.textContent.trim(), allDataEle);
      //data is an object which refers to row of old sheet
      fileProperties.filePath = data[i]['File Path'];
      fileProperties.fileSize = fileSize;
      fileProp = [fileProperties];
       cell = 'A' + (i+2);
      //inputWorksheet is referring to new sheet name
      XLSXReader.utils.sheet_add_json(inputWorksheet, fileProp, {
        skipHeader: true,
        origin: cell
      });
     XLSXReader.writeFile(workbook, excelSheetName.xlsx');

I am getting proper data but want to write the file sizes in the old sheet and not getting another sheet for this.

about 4 years ago · Juan Pablo Isaza
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