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

364
Visualizações
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
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