dtjohnson / xlsx-populate

Excel XLSX parser/generator written in JavaScript with Node.js and browser support, jQuery/d3-style method chaining, encryption, and a focus on keeping existing workbook features and styles in tact.
MIT License
956 stars 183 forks source link

Sheet order changing by simply reading and rewriting data to new file #342

Open NikhilCodes opened 2 years ago

NikhilCodes commented 2 years ago

I have this excel file. s3data1.xlsx

I have this simple snippet.

const again = await XlsxPopulate.fromFileAsync('./s3data1.xlsx').then((workbook) => {
      workbook.toFileAsync('test.xlsx');
      return workbook.outputAsync()
    });

And I see a file test.xlsx created test.xlsx

Now if you carefully look at both files. Content in 2nd tab of first sheet has shifted to 4th tab of 2nd sheet.

What am I doing wrong? Any help at the earliest would be appreciated.

mp3por commented 1 year ago

You only need the workbook.toFileAsync(). Calling workbook.outputAsync afterwards is not needed.

AmdEagle commented 3 months ago

@NikhilCodes Did you get this issue fixed as i am facing the same problem. Would like to know more info.

NikhilCodes commented 3 months ago

@AmdEagle what i had to do was, read the file using python pandas and save it again. After that the xlsx-populate doesnt glitch if you work on newly saved file. Reasons unknown. But works