EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

ConditionalFormatting Issue

Open st-dotnet opened this issue 1 year ago • 3 comments

Hi there, OfficeOpenXml.ConditionalFormatting.Contracts.IExcelConditionalFormattingRule format1 = sheet2.ConditionalFormatting.ElementAt(0); var test = format1.Node.ParentNode; I've recently upgraded from EpPlus version 5.0 to 7.0 and noticed that the IExcelConditionalFormattingRule.Node property has been removed from the ConditionalFormattingRule. Previously, I was using IExcelConditionalFormattingRule.Node.ParentNode to access certain functionalities. Could you kindly suggest an alternative approach or solution for this issue? Thank you.

st-dotnet avatar Feb 23 '24 17:02 st-dotnet

Conditional formattings are kept in memory from EPPlus 7 to get better performance, so the access to the XML DOM has been removed. If you are missing any functionality please let us know.

JanKallman avatar Feb 26 '24 07:02 JanKallman

Hi,

I am using this code using (var package = new ExcelPackage(newFile)) { ExcelWorksheet sheet1 = package.Workbook.Worksheets["Sheet1"]; OfficeOpenXml.ConditionalFormatting.Contracts.IExcelConditionalFormattingRule oldConditionalFormattingRule = sheet1.ConditionalFormatting.First(); X14CondtionalFormattingRule x14ConditionalFormattingRule = sheet1.X14ConditionalFormatting.X14Rules.First(); OfficeOpenXml.ConditionalFormatting.Contracts.IExcelConditionalFormattingRule format1 = sheet2.ConditionalFormatting.ElementAt(0); OfficeOpenXml.ConditionalFormatting.Contracts.IExcelConditionalFormattingRule format2 = sheet2.ConditionalFormatting.ElementAt(1); Assert.AreNotEqual(format1.Node.ParentNode, format2.Node.ParentNode); }

st-dotnet avatar Feb 26 '24 09:02 st-dotnet

Looks like you're trying to determine if a certain Conditional Formatting is part of the x14 namespace or what we call a Conditional Formatting with extLst.

Any particular reason for this? We made significant changes to conditional formatting so that we can support the reading and writing of all conditional formatting types without the user having to do any extra work. The "Node" property was removed as all the data is now held in different properties in memory. Comparing some of those instead might be more appropriate.

OssianEPPlus avatar Feb 26 '24 11:02 OssianEPPlus

Hi, got you, but is there any chance I can get the Node, like is there any other way to get this?

st-dotnet avatar Mar 07 '24 16:03 st-dotnet

Unfortunately no. We now essentially read in the data and only leave a placeholder node in the file until we write to it.

Why do you need the node? Only thing I can come to think of is to determine if it's an ExtLst ConditionalFormatting or not but a user shouldn't really have to worry about that. We do have internal properties that identify it however.

OssianEPPlus avatar Mar 12 '24 08:03 OssianEPPlus

Closed due to inactivity

OssianEPPlus avatar Apr 10 '24 08:04 OssianEPPlus