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

369
Views
How to edit and save excel file in fstp server

When I try to edit the excel file and upload it to the server, it writes the file but when I try to open it I get an error message "We found a problem with some content .xlsx error"

const uploadAttachment = async (arrayAttach) => {
    try {
        let sftp = new Client();
        await sftp.connect(config)
        const promises = arrayAttach.map(async attachment => {
            const workbook = new Excel.Workbook();
            await workbook.xlsx.load(attachment.buffer);
            workbook.worksheets[0].name = 'sheet1';
            const buffer = await workbook.xlsx.writeBuffer();
            sftp.put(buffer, `test/${attachment.originalname}.xlsx`);
        });
        Promise.all(promises)
            .then(results => {
                console.log('all files have been uploaded');
            })
            .catch(e => {
                logger.error(e)
                console.error(e);
            });
    } catch (err) {
        logger.error(err)
        console.log(err);
    }
}

Error message

But if I upload the file to the server without editing it I get it right, I attached a sample code

const uploadAttachmentOld = async (arrayAttach) => {
    try {
        let sftp = new Client();
        await sftp.connect(config)
        const promises = arrayAttach.map(async attachment => {
            logger.info(attachment)
            sftp.put(attachment.buffer, `test/${attachment.originalname}.xlsx`);
        });
        Promise.all(promises)
            .then(results => {
                console.log('all files have been uploaded');
            })
            .catch(e => {
                console.error(e);
            });
    } catch (err) {
        console.log(err);
    }
}

I would love if someone could help me understand where my mistake is

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!