Is it possible to find the frozen panes using EPPlus? For example, in the spreadsheet I'm working in, any row above 6 is frozen, and any column before D is frozen. Is there a way I can detect these in the given worksheet?
I know that EPPlus has an options to Freeze panes given the rows and columns. Browsing through the source code, I can see this method is located in ExcelWorksheetView.cs. Furthermore, the line that actually sets the state to frozen is: paneNode.SetAttribute("state", "frozen");
, where paneNode
is an XmlElement
.
Given this information, I used Visual Studio's debugger to search through the worksheet in an attempt to find relevant information regarding frozen state, but I have yet to find any information. I also checked if it was recorded within individual cells, but again, no luck.
I'm pretty new to this library and reading Excel files in general, and was hoping somebody more experienced would be able to help me located how exactly I can detect the frozen panes in a given worksheet.
I found a solution that works for me. The state of the main pane can be found in worksheet.View.TopNode.InnerXml
. Furthermore, so can the xSplit
and ySplit
values.
In order to reach these values:
var field = worksheet.View.GetType().GetProperty("TopNode", BindingFlags.NonPublic | BindingFlags.Instance);
XmlNode node = (XmlNode) field.GetValue(worksheet.View);
var pane = node.SelectSingleNode("//*[local-name()='pane']");
var state = pane.Attributes?["state"]?.Value;
var xSplit= pane.Attributes?["xSplit"]?.Value;
var ySplit= pane.Attributes?["ySplit"]?.Value;
From there I can check the state of the panel, as well as see the x and y positions of the split.