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

Images, formulas and checkboxes disappear #4280

Open
kboumedal opened this issue Dec 16, 2024 · 8 comments
Open

Images, formulas and checkboxes disappear #4280

kboumedal opened this issue Dec 16, 2024 · 8 comments

Comments

@kboumedal
Copy link

This is:

- [x] a bug report
- [ ] 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 current behavior?

Images (sheet "Accueil"), formulas (sheet "Data" cell C15) and checkboxes (sheet "Renovez votre maison) disappear after IOFactory::createWriter and save

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
        $spreadsheet = IOFactory::load(
[Simulateur_B_to_C_8.1_SANS_MACRO_2025 - Copie.xlsx](https://github.com/user-attachments/files/18151163/Simulateur_B_to_C_8.1_SANS_MACRO_2025.-.Copie.xlsx)
);

$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');

$temporaryPathfile = rtrim(sys_get_temp_dir(), \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR.md5(uniqid().mt_rand());

$writer->save($temporaryPathfile);

### What features do you think are causing the issue

- [ ] Reader
- [x] Writer
- [ ] Styles
- [ ] Data Validations
- [ ] Formula Calculations
- [ ] Charts
- [ ] AutoFilter
- [ ] Form Elements

### Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet 3.6, PHP8.3
@oleibman
Copy link
Collaborator

I have downloaded your spreadsheet, but don't understand what problems you are having.

  • Sheet Acceuil has at least some images on the copy. Which do you think are missing?
  • Agree that Data!C15 seems to contain a value rather than a formula.
  • Where are the checkboxes supposed to be on sheet "Renovez ..."?

Even given the answers to the questions above, this spreadsheet may be too complicated for me to debug. Might you be able to simplify it at all?

@oleibman
Copy link
Collaborator

The "value rather than formula" problem indicates we may not be handling "shared formulae" correctly. Here's what the xml has to say:

<c r="C14" t="b">
<f>IF(B14="oui",TRUE,FALSE)</f>
<v>0</v>
</c>
...
<c r="C15" t="b">
<f t="shared" si="0"/>
<v>0</v>
</c>

C15 is apparently using a "shared formula" derived from C14, but I don't see anything in C14 to suggest that it is a shared formula. I will need to research.

@oleibman
Copy link
Collaborator

The following xml lines may be relevant, in particular the line with ref:

<c r="C10" t="b">
<f>IF(B10="oui",TRUE,FALSE)</f>
<v>0</v>
</c>
...
<c r="C11" t="b">
<f t="shared" ref="C11:C16" si="0">IF(B11="oui",TRUE,FALSE)</f>
<v>0</v>
</c>

@oleibman
Copy link
Collaborator

Shared formulae work correctly on a much simpler spreadsheet. Whatever the problem is here, it seems specific to the more complicated spreadsheet.

@oleibman
Copy link
Collaborator

The problem seems to be the handling of shared formulae with a boolean result. Expect a fix for that problem in a day or two. I still need more information about the other problems.

@oleibman
Copy link
Collaborator

I believe the missing pictures (e.g. B8 on sheet Acceuil) are placed in the cells rather than over them. This is a very recent addition to Excel and we do not yet support it, which is why they are not found in the copy.

Still need more information about missing checkboxes.

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Dec 17, 2024
A solution, at least in part, for issue PHPOffice#4280. Xlsx Reader is not handling shared formulae correctly. As a result, some cells are treated as if they contain boolean values rather than formulae.
@kboumedal
Copy link
Author

Thanks for your quick response

Here is an image showing a checkbox disappearing in the "Renovez.." sheet

image

@oleibman
Copy link
Collaborator

Can you download your spreadsheet with sheet protection off, at least on the worksheet you want me to look at? Or, if you prefer, let me know the password to unprotect it.

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