You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.
If you have a large worksheet where multiple cells are merged, you'll notice that with each new range of merged cells it takes a little bit longer until, for large enough datasets, it becomes unworkable
I had this issue and assumed it was to do with large datasets. But when removing the title rows for each table, which included multiple pairs of merged cells, the document was created in a flash.
Logging timings, I noticed that for each new table, it would take longer and longer to fill it in.
Digging into the node module source code, I found the part handling merged cells and found the culprit. It's this part:
In lib/cell/inex.js, the mergeCells function
var okToMerge = true;
cellBlock.ws.mergedCells.forEach(function (cr) {
// Check to see if currently merged cells contain cells in new merge request
var curCells = utils.getAllCellsInExcelRange(cr);
var intersection = utils.arrayIntersectSafe(rangeCells, curCells);
if (intersection.length > 0) {
okToMerge = false;
cellBlock.ws.wb.logger.error('Invalid Range for: ' + cellRange + '. Some cells in this range are already included in another merged cell range: ' + cr + '.');
}
});
if (okToMerge) {
cellBlock.ws.mergedCells.push(cellRange);
}
The forEach function compares the cellrange with all currently merged cell ranges to check if it's safe to merge these new cells. I obviously understand the utility of this, but of course it means with each new merged range, you're increasing the length of this function for subsequent mergings.
When I commented out the forEach loop the document generated quickly again.
I didn't know if I should include this as a bug report or a feature request. But maybe there could be a general setting, or something passed to the cell() function, which allows for "unsafe" merging. The consequence would be risking the creation of failed excel documents, but so long as you're careful it's muuuuuuuuuch faster.
The text was updated successfully, but these errors were encountered:
If you have a large worksheet where multiple cells are merged, you'll notice that with each new range of merged cells it takes a little bit longer until, for large enough datasets, it becomes unworkable
I had this issue and assumed it was to do with large datasets. But when removing the title rows for each table, which included multiple pairs of merged cells, the document was created in a flash.
Logging timings, I noticed that for each new table, it would take longer and longer to fill it in.
Digging into the node module source code, I found the part handling merged cells and found the culprit. It's this part:
In lib/cell/inex.js, the mergeCells function
The forEach function compares the cellrange with all currently merged cell ranges to check if it's safe to merge these new cells. I obviously understand the utility of this, but of course it means with each new merged range, you're increasing the length of this function for subsequent mergings.
When I commented out the forEach loop the document generated quickly again.
I didn't know if I should include this as a bug report or a feature request. But maybe there could be a general setting, or something passed to the cell() function, which allows for "unsafe" merging. The consequence would be risking the creation of failed excel documents, but so long as you're careful it's muuuuuuuuuch faster.
The text was updated successfully, but these errors were encountered: