PhpSpreadsheet icon indicating copy to clipboard operation
PhpSpreadsheet copied to clipboard

WIP Limited Support for Form Controls (ListBox, Button, etc.)

Open oleibman opened this issue 3 years ago • 3 comments

Fix #2396. Fix #1770. Fix #2388. Fix #2661.

I am starting this out in draft status, and will probably leave it that way for some time. I'm not sure where we want to go with this. It fixes some problems, but in a limited manner, and creates some others. I'm not sure the pain of the others is balanced considering the limitations of the fix. If enough interest is generated as a result of this ticket being out there, we can proceed; if not, it probably isn't worth it.

This fix allows form control elements to be read in and written out. It does not allow you to add such elements, nor even to locate them or determine their properties (so you can't modify or delete them). Although it handles reading and writing of sheets containing both form controls and comments, it will probably create a corrupt spreadsheet if you try adding a new comment to a sheet with form controls - probably quite difficult to solve. Cloning the sheet probably won't work either - probably easier than the other. It is conceivable that we want to add a new property to the Xlsx Reader which turns the reading of form elements on or off (default=off), so that negative effects will be limited to those who have explictly opted in. The change in its current form does not implement such a property.

Because of its limitations, the change isn't really testable. As in some other recent installs, I have added a sample to demonstrate that it works correctly.

This is:

- [ ] a bugfix
- [x] a new feature

Checklist:

  • [x] Changes are covered by unit tests
  • [x] Code style is respected
  • [x] Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • [ ] CHANGELOG.md contains a short summary of the change
  • [ ] Documentation is updated as necessary

Why this change is needed?

oleibman avatar Dec 21 '21 02:12 oleibman

As it turns out, if we have a worksheet which contains both form controls and comments (see formscomments.xlsx which is part of this PR), PhpSpreadsheet already creates a corrupt file when it tries to load and save the spreadsheet with such a worksheet. I had thought the corruption occurred only after, say, adding a comment to the worksheet. Since the corruption is now known to be pre-existing and not a consequence of this change, it tilts things in favor of proceeding. I'm still not ready, but this will be an important consideration.

oleibman avatar Feb 13 '22 07:02 oleibman

A sample file for issue #2621 illustrated a problem with shape files. Since they are involved here, I took a look at how the sample worked with this code. In master, when loading and saving such a file, several shape files are lost, but Excel can read the file. Alas, with this change, a corrupt file results. Fixing that is probably easier than the general problem of handling shape files, but it's an argument against moving this forward until the corruption problem can be addressed.

oleibman avatar Feb 26 '22 04:02 oleibman

Fix #2661. A template including checkboxes was leading to file corruption solved by this PR. Another argument for moving forward.

oleibman avatar Mar 08 '22 15:03 oleibman

Closing, superseded by PR #3130.

oleibman avatar Oct 20 '22 04:10 oleibman