Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type definition for WorksheetModel.merges #2281

Merged
merged 2 commits into from
Sep 21, 2023

Conversation

ytjmt
Copy link
Contributor

@ytjmt ytjmt commented May 29, 2023

Summary

Closes #1341

Test plan

I confirmed the type is Range['range'][]:

  • // Merges
    model.merges = [];
    _.each(this._merges, merge => {
    model.merges.push(merge.range);
    });
  • _mergeCellsInternal(dimensions, ignoreStyle) {
    // check cells aren't already merged
    _.each(this._merges, merge => {
    if (merge.intersects(dimensions)) {
    throw new Error('Cannot merge already merged cells');
    }
    });
    // apply merge
    const master = this.getCell(dimensions.top, dimensions.left);
    for (let i = dimensions.top; i <= dimensions.bottom; i++) {
    for (let j = dimensions.left; j <= dimensions.right; j++) {
    // merge all but the master cell
    if (i > dimensions.top || j > dimensions.left) {
    this.getCell(i, j).merge(master, ignoreStyle);
    }
    }
    }
    // index merge
    this._merges[master.address] = dimensions;
  • const dimensions = new Range(cells);
    this._mergeCellsInternal(dimensions, true);

Copy link
Member

@Siemienik Siemienik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you

@Siemienik Siemienik merged commit 4abccf5 into exceljs:master Sep 21, 2023
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Typescript types not support worksheet.model.merges
2 participants