Skip to content
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

Editing Xlsx document does not preserve workbook attributes #523

Closed
billblume opened this issue May 31, 2018 · 2 comments
Closed

Editing Xlsx document does not preserve workbook attributes #523

billblume opened this issue May 31, 2018 · 2 comments

Comments

@billblume
Copy link
Contributor

This is:

- [ ] a bug report
- [x] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

Editing a Xlsx document using PhpSpreadsheet should preserve the workbook view attributes of that document. For example, if the worksheet tabs are hidden in the original document, they should remain hidden after updating.

What is the current behavior?

Editing a Xlsx document resets most workbook attributes to hardwired values.

See Writer\Xlsx\Workbook::writeBookViews. All workbook attributes except for 'activeTabs' are hardwired constants. For example, 'showSheetTabs' is always set to '1', meaning that worksheet tabs are always visible after updating.

What are the steps to reproduce?

  1. Create a Xlsx spreadsheet with multiple worksheets.
  2. Hide the worksheet tabs in that spreadsheet. (On a Excel 365 on Mac OS, go to Excel > Preferences > View and uncheck 'Sheet Tabs'.)
  3. Read the Xlsx spreadsheet with PhpSpreadsheet.
  4. Write the Xlsx spreadsheet.
  5. The worksheet tabs are now visible again.

Which versions of PhpSpreadsheet and PHP are affected?

This occurs in all versions of PhpSpreadsheet. This also occurs in PhpExcel.

@billblume
Copy link
Contributor Author

FYI. I am working on a PR for this issue.

billblume added a commit to billblume/PhpSpreadsheet that referenced this issue May 31, 2018
Fix for issue PHPOffice#523.  When reading then writing
a Xlsx spreadsheet, preserve the workbook bookview attributes for
the spreadsheet, (e.g., the attribute that hides worksheet tabs.)
Beforehand, these attributes were always being set to fixed constants.
billblume added a commit to billblume/PhpSpreadsheet that referenced this issue May 31, 2018
Made the following changes to fix PHPOffice#523
based on code-review comments.
* Updating workbook attributes is now done via a loop.
* Unit test no longer requires an input xlsx document.
billblume added a commit to billblume/PhpSpreadsheet that referenced this issue Jun 12, 2018
In response to feedback, the fix for issue PHPOffice#523 has been completely
rewritten.  This fix preserves workbook view attributes when one
reads and writes Xlsx documents.  The old code did this by storing
all workbook attributes in a single map.  The new code stores
each attribute as a separate property with its own gettor and settor
methods.
billblume added a commit to billblume/PhpSpreadsheet that referenced this issue Jun 12, 2018
Fix for issue PHPOffice#523.  When reading then writing
a Xlsx spreadsheet, preserve the workbook bookview attributes for
the spreadsheet, (e.g., the attribute that hides worksheet tabs.)
Beforehand, these attributes were always being set to fixed constants.
billblume added a commit to billblume/PhpSpreadsheet that referenced this issue Jun 12, 2018
Made the following changes to fix PHPOffice#523
based on code-review comments.
* Updating workbook attributes is now done via a loop.
* Unit test no longer requires an input xlsx document.
billblume added a commit to billblume/PhpSpreadsheet that referenced this issue Jun 12, 2018
In response to feedback, the fix for issue PHPOffice#523 has been completely
rewritten.  This fix preserves workbook view attributes when one
reads and writes Xlsx documents.  The old code did this by storing
all workbook attributes in a single map.  The new code stores
each attribute as a separate property with its own gettor and settor
methods.
billblume added a commit to billblume/PhpSpreadsheet that referenced this issue Jun 13, 2018
Fix for issue PHPOffice#523.  When reading then writing
a Xlsx spreadsheet, preserve the workbook bookview attributes for
the spreadsheet, (e.g., the attribute that hides worksheet tabs.)
Beforehand, these attributes were always being set to fixed constants.
billblume added a commit to billblume/PhpSpreadsheet that referenced this issue Jun 13, 2018
Made the following changes to fix PHPOffice#523
based on code-review comments.
* Updating workbook attributes is now done via a loop.
* Unit test no longer requires an input xlsx document.
@PowerKiKi
Copy link
Member

Thanks for this great addition ! I moved the tests as functional test and merged it.

Dfred pushed a commit to Dfred/PhpSpreadsheet that referenced this issue Nov 20, 2018
Editing a Xlsx document using PhpSpreadsheet should preserve the workbook
view attributes of that document. For example, if the worksheet tabs are
hidden in the original document, they should remain hidden after updating.

Fixes PHPOffice#523
Fixes PHPOffice#525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants