-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
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)
I'm using Excel 2019, php 7.4, and the master branch of PhpSpreadsheet
It seems as though the Xlsx Reader does not read the legacyDrawing element. If you read in an xlsm that contains a FormControl button and then save the spreadsheet, the button will be missing when you open the newly saved file. If you unzip the newly saved file, add back the missing legacyDrawing element, and re-zip then the button will be available.
What is the expected behavior?
The saved xlsm retains the button
What is the current behavior?
The saved xlsm no longer has the button
What are the steps to reproduce?
- Open Excel 2019
- Create a blank workbook
- Add a button -> click the Developer tab, then Insert, then select the box icon under Form Controls
- In the AssignMacro window, record a new marco. Use the default values. The recorded macro can be whatever you want. I just clicked a random cell and gave it a fixed value (e.g. the character 'a').
- Save the file anywhere you want and call it 'test.xlsm'.
- Run the code below:
<?php
require __DIR__ . '/vendor/autoload.php';
$reader = new XlsxReader();
$sheet = $reader->load('path/to/test.xlsm');
$writer = new XlsxWriter($sheet);
$writer->save('path/to/test_2.xlsm');- Open 'test_resaved.xlsm' and you'll find there is no button.
Optional
- Unpack both
test.xlsmandtest_resaved.xlsmusing your favorite unzip program (I used WinRAR) - Open and compare
path/to/test/xl/worksheet/sheet1.xmlandpath/to/test_resaved/xl/worksheet/sheet1.xml - Somewhere in the file you'll find an element called
<drawing>and they will be the same in both files - In the test version of
sheet1.xmlyou'll also find a<legacyDrawing>element. That element will be missing from the test_resaved version. - Copy-paste the legacy drawing element
- Recreate
test_resaved.xlsmby zipping everything up again (I used WinRAR, fastest) - Open
test_resaved.xlsmand you see the button.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels