Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupt file on windows #732

Open
Zoharyal opened this issue Jan 23, 2019 · 2 comments
Open

Corrupt file on windows #732

Zoharyal opened this issue Jan 23, 2019 · 2 comments
Labels

Comments

@Zoharyal
Copy link

Zoharyal commented Jan 23, 2019

I'm writing on a blank xlsx file, created on windows. The file is corrupted on windows, i can open it on libreoffice on my laptop, google sheets on google drive open it too. Only excel on windows cannot open it.

    const workbook = new Excel.Workbook();
    const filename = 'Export_positionnement_apprenant.xlsx';
    let chemin = '';
    let cheminFinal = '';
    chemin = path.join(__dirname, '../../../modeles/');
    cheminFinal = path.join(__dirname, '../../../tempUploads/');
    chemin += 'Export_planning_windows.xlsx'; // modele vide
    await workbook.xlsx.readFile(chemin);
    const worksheet = workbook.getWorksheet('Sheet1');
if (worksheet) {
      const rowToAdd = [];
      // let row = worksheet.getRow(1);
      // if (!row) {
      //   worksheet.addRow();
      //   row = worksheet.getRow(1);
      // }
      // row.values = infoRow;
      // row.height = 50;
      worksheet.addRows(infoRow);
      let intervRow = worksheet.getRow(8);
      intervRow.values = intervInfo;
      let dayRow = worksheet.getRow(7);
      dayRow.values = daysRow;
      for (const app of appRow) {
        rowToAdd.push([app.nom].concat(app.client, app.indices, app.tranche));
      }
      worksheet.addRows(rowToAdd);

      autofitColumns(worksheet);
      worksheet.eachRow((r, rowNumber) => {
        if (rowNumber > 1) r.height = 50; // eslint-disable-line
        r.eachCell((cell, cellNumber) => {
          cell.alignment = { vertical: 'middle', horizontal: cellNumber === 1 ? 'left' : 'center' }; // eslint-disable-line
        });
      });
      await workbook.xlsx.writeFile(cheminFinal + filename);
      return { cheminFinal, filename }
    }

Thanks for any idea

@Gildewarz777
Copy link

I seem to have the same problem here. What happens if you create a simple file with nothing on it, just a spreadsheet?

@starl441
Copy link

starl441 commented Sep 6, 2024

I have similar issues. Is this resolved and how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants