Skip to content

BorderAround() silently drops the Bottom (and sometimes Right) border side in EPPlus 8.x #2525

Description

@devguyky

EPPlus usage

Commercial use (I have a commercial license)

Environment

Windows 11, .NET 10

Epplus version

Regression present in 8.0.1 through 8.7.0 (latest tested). Confirmed working correctly in 7.7.3.

Spreadsheet application

Microsoft Excel

Description

Description

ExcelRangeBase.Style.Border.BorderAround(style) no longer reliably writes the Bottom border side (and inconsistently the Right side) to the workbook's styles.xml when called on individual cells in a loop. This results in missing bottom borders on printed/exported sheets — most noticeably on the last row of a bordered table, since internal rows visually "borrow" a border from the adjacent row's Top edge, but the final row has nothing below it to compensate.

This worked correctly in EPPlus 7.7.3 and regressed sometime before/at 8.0.1. It does not appear to be listed on the Breaking Changes in EPPlus 8 wiki page. It may be a side effect of the change made for #736 (connecting-cell border override), but the resulting behavior here is not a "widest border wins" cosmetic difference — the Bottom side is dropped from the XML entirely.

Workaround

Set each side explicitly instead of calling BorderAround():

cell.Style.Border.Top.Style = style;
cell.Style.Border.Bottom.Style = style;
cell.Style.Border.Left.Style = style;
cell.Style.Border.Right.Style = style;

This produces the correct 4-sided border XML in 8.7.0.

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