I have a code that read an excel file that was input and post the data into a mysql database. The problem is that sometimes, not always, when I post the method, i receiv the following error: Error: Corrupted zip : can't find end of central directory, so I want to try again until it works .. I use the library XLSX-Populate to parse the data

import { createConnection } from "typeorm";

const XlsxPopulate = require('xlsx-populate');

export async function xlsxImportParser(filePath: string): Promise<string> {
    let response: string;
    await XlsxPopulate.fromFileAsync(filePath, {encoding:'base64'}) // Leio o XLSX
        .then(async workbook => { // Dou uma variavel pra planilha, pra acessar os dados dela
            let recordsAdded = 0; // Crio uma variavel com total de itens na planilha
            await TempHomologados.delete({});
            for(let i = 2; i < workbook.sheet(0)._rows.length; i++) { // Faco um for, para cada linha da planilha, eu adicionar um registro no banco de dados, comecando por 1, porque a linha 0 e o cabeçalho
                try {
                    let temp_homologados = await TempHomologados.findOne({ codigo_candidato: workbook.sheet(0).cell(`B${i}`).value()});
                    let newPessoa = false;
  • any update on a solution that might have worked for you here? – Mansi Dec 6 '19 at 3:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.