Skip to content

Commit

Permalink
fix(sheet): fix the issue of incorrect number of merged cells in the …
Browse files Browse the repository at this point in the history
…format painter (#1526)

Co-authored-by: yuanbin <ybzkyfafa@gamil.com>
  • Loading branch information
ybzky and yuanbin committed Mar 19, 2024
1 parent 8685e14 commit cd9b6f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Expand Up @@ -300,6 +300,34 @@ describe('Test format painter rules in controller', () => {
expect(workbook.getSheetBySheetId('sheet-0011')?.getMergeData()[0].startRow).toBe(1);
expect(workbook.getSheetBySheetId('sheet-0011')?.getMergeData()[1].startRow).toBe(1);
expect(workbook.getSheetBySheetId('sheet-0011')?.getMergeData()[2].startRow).toBe(3);

await commandService.executeCommand(SetSelectionsOperation.id, {
unitId: 'workbook-01',
subUnitId: 'sheet-0011',
pluginName: NORMAL_SELECTION_PLUGIN_NAME,
selections: [
{
range: {
startRow: 0,
endRow: 1,
startColumn: 0,
endColumn: 1,
},
},
],
});

await commandService.executeCommand(SetOnceFormatPainterCommand.id);
await (formatPainterController as any)._applyFormatPainter({
startRow: 10,
endRow: 13,
startColumn: 12,
endColumn: 13,
});
const mergeData = workbook.getSheetBySheetId('sheet-0011')?.getMergeData();
expect(mergeData?.length).toBe(5);
expect(mergeData?.[3].startRow).toBe(11);
expect(mergeData?.[4].startRow).toBe(13);
});
});
});
Expand Down
Expand Up @@ -104,6 +104,7 @@ export class FormatPainterService extends Disposable implements IFormatPainterSe

const styles = workbook.getStyles();
const stylesMatrix = new ObjectMatrix<IStyleData>();
this._selectionFormat.merges = [];
for (let r = startRow; r <= endRow; r++) {
for (let c = startColumn; c <= endColumn; c++) {
const cell = cellData.getValue(r, c) as ICellData;
Expand Down

0 comments on commit cd9b6f8

Please sign in to comment.