Skip to content

Column style is lost on remaining columns when a sub-range column style is modified #2471

Description

@lievendf

Steps to Reproduce

  1. Set a column style (e.g. Font.Size = 9) across a range of columns (e.g. A:J).
  2. Modify a style property (e.g. Font.Bold = true) on a sub-range of those columns (e.g. B:C).
  3. Set a value in a cell located in one of the remaining columns of the original range (e.g. cell E1).

Observed Behavior

Cell E1 loses the font size set in step 1 and reverts to the default font size (11pt).

Expected Behavior

Cell E1 retains font size 9 set in step 1.

Minimal Reproducible Code

[TestMethod]
public void MultiColumnStyle_WhenSplitBySubRange_ShouldInheritStyle()
{
    using (var p = new ExcelPackage())
    {
        var ws = p.Workbook.Worksheets.Add("TestSheet");

        // 1. Set font size 9 on columns A to J
        ws.Cells["A:J"].Style.Font.Size = 9;

        // 2. Modify a style property on sub-range B:C
        ws.Cells["B:C"].Style.Font.Bold = true;

        // 3. Populate cell E1 in column E
        ws.Cells["E1"].Value = "Test";

        // Expected: Font size 9
        // Actual:   Font size 11 (Assert.AreEqual failed. Expected:<9>. Actual:<11>.)
        Assert.AreEqual(9f, ws.Cells["E1"].Style.Font.Size, "Cell E1 font size should be 9");
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions