I am dynamically creating an Excel workbook with multiple sheets using ClosedXML. I am struggling changing the sheet selected back to the first sheet in the workbook after I am done generating the content and cannot find anything in the documentation on how to change the sheet that is displayed. I have tried:
wb.Worksheet(1).Select();
This selects all of the cells in the worksheet, but it doesn't change the view back.
wb.Worksheet(1).Cells(1,1).Value = wb.Worksheet(1).Cells(1,1).Value
seems to set the value, but again doesn't change the view.
I have tried hiding the other sheets in hopes that it would auto select the visible sheets, but that does not seem to work. Any suggestions?
Using ClosedXML to set the Active Sheet to the first worksheet one would use this code:
wb.Worksheet(1).SetTabActive();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With