Closed gdereese closed 2 weeks ago
EPPlus copies the workbook internal worksheet xml, so the selected flag will also be copied to the new worksheet. I can agree that this is likely not the intended behaviour, so we will change this. We will look at adding an argument to the copy worksheet function to either keep the selection or set the new worksheet as the selected. As this will be a breaking change, the change will go into 7.4 or 8.0
Fix added in EPPlus 7.3.1 - Adds a parameter to ExcelWorksheet.Add to select the copied worksheet or leave the selection as is.
EPPlus usage
Commercial use (I have a commercial license)
Environment
Windows
Epplus version
7.2.2
Spreadsheet application
Excel
Description
Scenario
Template.xlsx
exists that contains 2 sheets: Sheet 1 and Sheet 2. Sheet 1 contains a chart.ExcelPackage
.Report.xlsx
.Report.xlsx
in Excel on the machine.Expected behavior
When copying a single worksheet from within Excel, the new sheet copy is NOT selected; the original sheet being copied remains the selected sheet.
Workaround
There are 2 workarounds:
Sample code
The following C# console program code reproduces the issue:
Sample Excel template
Template.xlsx