Active tab is not set correctly on inserting sheet at the front
See original GitHub issueDo you want to request a feature or report a bug?
- Bug
- Feature
Version of ClosedXML
0.94.2 and latest build
What is the current behavior?
Given a new empty excel file with one sheet.
Execute the following code:
this.worksheet = this.workbook.Worksheets.Add("NewFrontSheet", 1);
Afterwards open the file in Excel. Note that both the first and second sheet are selected and the first sheet is active.
If the sheet is added in position 2 note that the result will have only one sheet active and selected.
What is the expected behavior or new feature?
The active worksheet should correctly be kept when adding a new sheet in first position.
Did this work in previous versions of our tool? Which versions?
unknown
Reproducibility
Code to reproduce problem:
class Program
{
private XLWorkbook workbook;
private IXLWorksheet worksheet;
static void Main(string[] args)
{
Program p = new Program();
p.Test();
}
private void Test()
{
this.workbook = new XLWorkbook(@"T:\tmp\test.xlsx");
this.worksheet = this.workbook.Worksheets.Add("NewFrontSheet", 1);
this.workbook.Save();
}
}
I assume this is an issue with how workbookView.activeTab is handled, since TabActive does return false for the single sheet directly after new XLWorkbook(…). The initial value in workbook.xml is not set (should default to 0).
I hope this helps.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top GitHub Comments
@Pankraty Yes, that fixes the problem I am seeing. Thanks a lot! ✨
@Pankraty If I select the second sheet activeTab is set to ‘1’. TwoSheetsSecondSelected.xlsx