-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat: add drawing pass-through support for unsupported elements #4712
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
base: master
Are you sure you want to change the base?
Conversation
96f2fd7 to
cb8ab8e
Compare
cb8ab8e to
f34facf
Compare
|
I am still evaluating whether this is a good idea or not. Will it work if you add or remove a row or a column on the sheet? Add a comment when there weren't any before, and when there were? Remove a comment? Your commentary says that you are fixing 3 open issues. Are there tests for each of those? |
b7456c3 to
bafbad2
Compare
47e62af to
4061cc0
Compare
4061cc0 to
cf40574
Compare
Yes but the drawing's coordinates (col, row, offsets) will not be adjusted.
Comments are completely independent from drawings.
I was too quick when referencing the issues, this PR actually only addresses one of them. I added several unit tests, including checks for unsupported elements (shapes/textboxes), behavior without pass-through, comment deletion, row/column operations, and correct flag handling between the Reader and Writer. This feature isn’t ideal, as it’s essentially a workaround, but it will provide a temporary solution while we wait for those implementations, and it will help avoid patching the code. |
|
Thank you for adding the tests. Comments are, alas, not completely independent from drawings. It's why I asked the question. Create a new spreadsheet with a comment. Notice that there is a drawings folder with a vml file in it in the saved spreadsheet. I can't offhand tell whether this will be a problem for your change. |
358e212 to
f050b86
Compare
|
I have added testCommentsAndPassThroughCoexist |
|
It is not absolutely required that Coveralls doesn't report a decrease. However, we strive to eliminate that situation if possible, especially in code which is new in a change. In Writer\Xlsx\Drawing.php, you have the following new statements which include some "misses" around line 617: if (!isset($unparsedLoadedData['sheets'][$codeName])) {
return null;
}
$sheetData = $unparsedLoadedData['sheets'][$codeName];
if (!is_array($sheetData)) {
return null;
}
// Only use pass-through XML if the Reader flag was explicitly enabled
if (($sheetData['drawingPassThroughEnabled'] ?? false) !== true) {
return null;
}
if (!isset($sheetData['Drawings']) || !is_array($sheetData['Drawings'])) {
return null;
}I tthink if you changed that block as follows, your code would still work as planned and there would no longer be any coverage misses: $sheetData = $unparsedLoadedData['sheets'][$codeName] ?? null;
// Only use pass-through XML if the Reader flag was explicitly enabled
if (!is_array($sheetData) || ($sheetData['drawingPassThroughEnabled'] ?? false) !== true || !is_array($sheetData['Drawings'] ?? null)) {
return null;
}Please give that a shot. |
|
Thank you - success on both fronts - no problems with unit tests, and no missed statements. |
feat: add drawing pass-through support for unsupported elements
Add opt-in pass-through mechanism to preserve unsupported drawing
elements (shapes, textboxes etc) during read/write operations.
This allows preservation of Excel elements not yet supported by
PhpSpreadsheet without requiring full implementation.
Currently, the pass-through mechanism works as follows:
setEnableDrawingPassThrough(true)stores the original drawing XMLI'm open to adding an explicit Writer flag if you believe it provides better clarity and control.
This addresses existing issue : #4037