Open jtrent614 opened 1 year ago
We'll have a look at this.
Thanks Jan. I think this may be related to a similar problem I'm having, which is trying to set something like Worksheet.View.TopLeftCell = "B2"
where it also has issues with hidden rows/columns. I'll test this a little more and document it.
Ok, I tried this...
[TestMethod]
public void FreezePanes()
{
using (var p = OpenPackage("Freeze.xlsx", true))
{
var ws = p.Workbook.Worksheets.Add("Sheet1");
ws.Column(1).Hidden = true;
ws.Row(1).Hidden = true;
ws.View.FreezePanes(3, 3);
SaveAndCleanup(p);
}
}
This seems to work as expected and freezes on C3
// Test 1 (row 1/col A already hidden) - FAIL
var ws = excelFile.Workbook.Worksheets["Sheet1"];
ws.View.FreezePanes(3, 3);
// Test 2 - FAIL
var ws2 = excelFile.Workbook.Worksheets["Sheet2"];
ws2.Column(1).Hidden = true;
ws2.Row(1).Hidden = true;
ws2.View.FreezePanes(3, 3);
// Test 3 - PASS
var ws3 = excelFile.Workbook.Worksheets.Add("Sheet3");
ws3.Column(1).Hidden = true;
ws3.Row(1).Hidden = true;
ws3.View.FreezePanes(3, 3);
Looks like the issue is isolated to when when you have a pre-existing worksheet in the file instead of creating the worksheet first. Forgot to mention this is happening in 6.0.8 and 6.1.2.
When calling
ExcelWorksheetView.FreezePanes(int Row, int Column)
, theRow
andColumn
coordinates ignore hidden rows/columns and instead count only visible rows/cols.Steps to reproduce:
Worksheet.View.FreezePanes(3, 3)
XML Examples