exceljs icon indicating copy to clipboard operation
exceljs copied to clipboard

[BUG] duplicateRow create corrupted file when duplicating row with merged cells

Open OB42 opened this issue 3 years ago • 0 comments

🐛 Bug Report

When using duplicateRow on a sheet with merged cells, I get a corrupted file when I save the workbook. It seems that the same text from the merged cells is copied in multiple cells instead of copying merged cell. Errors when opening the file in excel:

"We found a problem with some content in ’copy.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes."

"Excel was able to open the file by repairing or removing the unreadable content."

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>Repair Result to copy5.xml</logFileName><summary>Errors were detected in file ’/Users/mac/copy.xlsx’</summary><removedRecords summary="Following is a list of removed records:"><removedRecord>Removed Records: Conditional formatting from /xl/worksheets/sheet1.xml part</removedRecord></removedRecords></recoveryLog>

Lib version: 4.3.0

Steps To Reproduce


const workbook = new Excel.Workbook();
workbook.xlsx.readFile("./test.xlsx").then(function () {
    const ws = workbook.getWorksheet(1);
    ws.duplicateRow(1, 1, false);//there is merged cells on row 1

    workbook.xlsx.writeFile("copy.xlsx").then(() => {
        console.log("done!");
    });
});

The expected behaviour:

Well it should copy the merged cells correctly

OB42 avatar Sep 20 '22 07:09 OB42