EPPlus set default worksheet
Asked Answered
C

3

5

I am using EPPlus v4.1 to generate an excel file in C#.

Is there a way to set a specific worksheet as the default worksheet? (when the user is opening the exported file, that sheet should be shown)

I could not find a method or property on ExcelWorkbook or ExcelWorksheets classes.

Consistent answered 12/12, 2019 at 16:19 Comment(0)
C
6

I found the answer meanwhile. I don't want to delete the question because it might be useful to someone else.

//this line sets the first tab in the excel file as default/active
    Workbook.Worksheets.First().Select();
Consistent answered 12/12, 2019 at 16:37 Comment(0)
W
1

For EPPlus 5 the answer is:

sheet.View.SetTabSelected();
Wrap answered 7/1, 2022 at 13:10 Comment(0)
H
0

None of the other answers worked in my case (not sure what was specific about my particular case), but I was able to set the active worksheet using the below (using EPPlus v4.5.3.3):

excelPackage.Workbook.View.ActiveTab = worksheet.Index;
Harangue answered 18/7, 2023 at 11:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.