-
Notifications
You must be signed in to change notification settings - Fork 807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Active tab is not set correctly on inserting sheet at the front #1383
Comments
@_all you see what happens when the issue template is thoroughly filled? :D |
I don't think #1384 fully resolves the general issue. Note that "IsActive" still returns false for the test.xlsx. From what I see "IsActive" should be set to the 1st tab if workbook.activeTab is not set (since according to the documentation the default value is 0) when loading the xlsx. So another bug would occur in my opinion when after adding 'NewFrontSheet' it is set as TabSelected. This would result in it being also TabActive when saving, while the correct behavior should be that the prior active tab should remain active. |
@ChristophHornung I think the main reason is that your file does not have any tab marked as active. How did you get such file? When I try to reproduce the issue on a fresh file there is always an active tab present. Moreover, if I manually remove So I think it is best to specify the active tab explicitly if it is not set. Anyway, I've prepared a fix for this too. |
… specified in file (ClosedXML#1383)
@Pankraty test.xlsx was just "open excel (excel from office 365) - create new file (empty) - save" |
@Pankraty Even if I open a new empty file and add an additional sheet and then re-select the first one the workbookview.activeTab is still unset. |
Can you please check if the artifacts from this build fix the issue? |
@Pankraty If I select the second sheet activeTab is set to '1'. |
@Pankraty Yes, that fixes the problem I am seeing. Thanks a lot! ✨ |
Do you want to request a feature or report a bug?
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:
test.xlsx
result.xlsx
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.
The text was updated successfully, but these errors were encountered: