Monday, 3 April 2023

Why my excel is corrupt when adding data?

This code is supposed to add "ABC" in B3, but when writing the document, its size goes to 0ko (original is ~200ko) and Excel refuse to open it up.

const modele = "./myexcel.xlsx"

var workbook = new excel.Workbook();
workbook.xlsx.readFile(modele)
.then(function() {
    var worksheet = workbook.getWorksheet('Personnel');

    worksheet.getCell('B3').value = "ABC";
    
    return workbook.xlsx.writeFile(modele)

});

I don't want to create a new sheet but to write in an existing one

I tried using stream, writing in a new file and different version of this code but it doesn't seems to work.

I'm using ExcelJS before for the same purpose and it work.

The cell B3 is in a table I want to add a lot of data in.



from Why my excel is corrupt when adding data?

No comments:

Post a Comment