Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

367
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda