EPPlusSoftware / EPPlus

EPPlus-Excel spreadsheets for .NET
https://epplussoftware.com
Other
1.74k stars 273 forks source link

Setting TopLeftCell in a template with Frozen columns Breaks both scroll and frozen columns #352

Open EmaGht opened 3 years ago

EmaGht commented 3 years ago

Repository is still this: https://github.com/EmaGht/EPPLUS_Bug Latest developer build of EPPLUS is installed so this (https://github.com/EPPlusSoftware/EPPlus/issues/347) is not a problem anymore, but now i added the showcase of the bug happening when setting the TopLeftCell (Line 19 of Program.cs)

Forgive me for nagging you this much

JanKallman commented 3 years ago

The topLeftCell attribute set by the TopLeftCell is done on the sheet view, so this applies to the bottom right pane. From the OOXML documentation:

Location of the top left visible cell Location of the top left visible cell in the bottom right pane (when in Left-to-Right mode).

I think this has to be set on the pane element that currently is not exposed as a property ...

<pane xSplit="7" ySplit="7" topLeftCell="H56" activePane="bottomRight" state="frozen"/>

We will look into adding support for this.

EmaGht commented 3 years ago

It seems more complex than what i thought it should be... Just to be sure we are talking about the same functionality, can you confirm to me that the

ws.View.TopLeftCell = "A1"

Of EPPLUS is supposed to work the same as

ws.Range["A1", "A1"].Select();

Of the COM?

If that's the case i will gladly wait until you manage to implement it! That's currently the only thing that's stopping us to get a commercial license :P

Thanks!

JanKallman commented 3 years ago

I thing we have to deep dive into how it should work. You have the panes today in ws.View.Panes and we should liklely implement it there. It look like this in the worksheet xml:

<sheetViews>
<sheetView tabSelected="1" zoomScaleNormal="100" workbookViewId="0">
<pane xSplit="7" ySplit="7" topLeftCell="H8" activePane="bottomRight" state="frozen"/>
<selection activeCell="A6895" sqref="A6895:G6918"/>
<selection pane="topRight" activeCell="A6895" sqref="A6895:G6918"/>
<selection pane="bottomLeft" activeCell="A6895" sqref="A6895:G6918"/>
<selection pane="bottomRight" activeCell="M19" sqref="M19"/>
</sheetView>
</sheetViews>
EmaGht commented 3 years ago

I'm doing a LOT of assumptions here, but... I imagine a single cell should never be part of two different Panes, this means that maybe setting TopLeftCell on Worksheet.View could just get the Pane on which this Address is contained and set the topLeftCell of the correct Pane?

Understanding why the Excel file in my example gets THAT damaged when setting TopLeftCell on the wrong(?) Pane could definitely help me understand what's the exact problem here but I'm afraid it's a bit too much for me considering the time i have at hand ^.^"

Let me know if there is something i can do to help you out with this!

JanKallman commented 3 years ago

We will look into this as it seems like a function that should be there. I'll add this as an enhancement for the next version.

EmaGht commented 3 years ago

I updated my repository (https://github.com/EmaGht/EPPLUS_Bug) with an example using Microsoft COMs,

Hope it's gonna be handy to check for the desired beahviour