Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!