Search code examples
c#asp.netopenxmlopenxml-sdk

Set focus on particular sheet while exporting excel in multiple sheets


I'm using OpenOfficeXML to write data in excel workbook in my c# application. That contains multiple sheets and data.

I want to make the focus on the 2nd sheet by default on completion of data writing.


Solution

  • try setting the WorkBookView.ActiveTab property to 2 after you're done writing your data to .xlsx but before you're going to call workBook.Save():

    workBookView.ActiveTab = 2;