Corrupt xlsx after updating
See original GitHub issueHello, great lib, I have an issue with the following code whereby the updated file become corrupt. The val you see in code is a string version of a bool so “true” or “false”, I did hardcode a string as val (“hello”), just to see if it was the bool that caused the issue, but the file still got corrupted. Can you please take a look and see what I may be doing wrong, thanks. If I am able to recover the file, it has the updated value, but my app is no longer able to read the file for subsequent parsing
function updateExcelEntry(inputPage,sheet,colKeyIndex,colIndexToUpdate,rowKey,val){
//console.log("in excel " + inputPage);
var workbook = new Excel.Workbook();
workbook.xlsx.readFile(inputPage).then(function() {
// use workbook
//console.log("getting sheet " + sheet);
var worksheet = workbook.getWorksheet(sheet);
//console.log("getting keyCol " + colKeyIndex);
var keyCol = worksheet.getColumn(colKeyIndex);
keyCol.key = "key";
var col = worksheet.getColumn(colIndexToUpdate);
col.key = "colToUpdate";
worksheet.eachRow(function(row, rowNumber) {
//console.log("checking key val " + row.getCell("key").value);
//console.log("vs rowKey " + rowKey);
if(rowNumber !== 1 && row.getCell("key").value === rowKey){
//console.log("Row " + rowNumber + " = " + JSON.stringify(row.values));
row.getCell("colToUpdate").value = val;
}
});
}).then(function() {
return workbook.xlsx.writeFile(inputPage)
}).then(function() {
console.log("workbook updated " + inputPage);
});
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:5
- Comments:19
Top Results From Across the Web
Repairing a corrupted workbook - Microsoft Support
Repair a corrupted workbook manually · On the File tab, click Open. · In Excel 2013 or Excel 2016, click on the location...
Read more >7 Ways to Repair Damaged and Corrupt Excel Files
This page offers the 7 best ways to repair damaged and corrupt excel files, the best Excel file repair tool to help you...
Read more >How to Open Corrupt Excel XLS and XLSX Files?
Click Browse to select the corrupt Excel XLS or XLSX file. The File Open window will pop on-screen now; select the corrupt Excel...
Read more >Get rid of "The file is corrupt and cannot be opened" in Excel
How to open a corrupt xls. file in Excel 2010 - 365 · Open Excel. · Click on File -> Options. · Select...
Read more >[Fixed] The File Is Corrupted and Cannot Be Opened in Excel ...
The changes of settings in Microsoft Office after upgrading or reinstallation · Protection of your computer against the files come from another ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I solved the problem by using:
https://www.npmjs.com/package/xlsx-populate
All sorts of small formatting problems simply disappeared. I cannot recommend it enough.
I have same issue. After read the latest comments i make a test. Make a simple script that only read and write on different file.
First test:
Second test:
So something is different in LibreOffice/OpenOffice files.