Skip to content

XLBorderStyleValues.None is incorrect on ConditionalFormat #2401

Open
@miyamoto13

Description

Read and complete the full issue template

Do you want to request a feature or report a bug?

  • Bug
  • Feature
  • Question

Did you test against the latest CI build?

  • Yes
  • No

Version of ClosedXML

0.102.3

What is the current behavior?

Firstly, set up formatting in Excel as shown in the attached file.

Steps to make this Excel file:

  1. Set the border of the cells to "thin" around the outer edges using the standard style.
  2. Configure Conditional Formatting as shown in the attached image.
    Screenshot 1
    Screenshot 2

When opening the Excel file, it displays as shown in the attached image.
Screenshot 3

However, when copying the file using ClosedXML and saving it as is, the display changes as shown in the attached image.
Screenshot 4

After tracing through the ClosedXML code, it seems that when copying a cell with a border set to "None", the value XLBorderStyleValues.None is applied.
When saving the file in this state, the border does not remain "None" state but instead reverts to the default border style.

What is the expected behavior or new feature?

In Excel, a border set to "None" and the default border are treated as different states, so I would appreciate it if ClosedXML could handle them as distinct states as well.

Is this a regression from the previous version?

n/a.

Reproducibility

Code to reproduce problem:

using ClosedXML.Excel;
public void Main()
{
    var workbook = new XLWorkbook("path/to/source.xlsx");

    // additional ConditionalFormatting for test
    var worksheet = workbook.Worksheet(1);
    worksheet.Cell("D5").AddConditionalFormat().WhenBetween(1, 5).Border.SetTopBorder(XLBorderStyleValues.None);

    workbook.SaveAs("path/to/destination.xlsx");
}
  • I attached a sample spreadsheet. (You can drag files on to this issue)
    source.xlsx

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions