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

Error in part of the content in the book... #4270

Open
1 task
Cleverscript opened this issue Dec 10, 2024 · 1 comment
Open
1 task

Error in part of the content in the book... #4270

Cleverscript opened this issue Dec 10, 2024 · 1 comment

Comments

@Cleverscript
Copy link

Cleverscript commented Dec 10, 2024

What is the expected behavior?

Numeric data cells are missing extra characters

What is the current behavior?

Why for numeric values ​​in cells, the first character before this number, is added a single quote. This leads to an error in Microsoft Excel. I added a condition that if the value = is_numeric, then we set DataType::TYPE_NUMERIC for setValueExplicit. But there are numbers in the form of a date 04.09.2024 or such as 47.91.2 and this did not work with them ... How to solve the problem with them if TYPE_NUMERIC for them leads to a Fatal error ?

What are the steps to reproduce?

->setValueExplicit('04.09.2024', DataType::TYPE_STRING);

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

->setValueExplicit('04.09.2024', DataType::TYPE_STRING);

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

  • Writer

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Xlsx

Which versions of PhpSpreadsheet and PHP are affected?

<=1.28

report_2024-11-27.xlsx

artefact_2

@oleibman
Copy link
Collaborator

I am not sure what you are asking. 5 can be interpreted as a number or as a string, which is why you can add the leading apostrophe to make Excel treat it as a string. However, 04.09.2024 and 47.91.2 are unambiguously strings, not numbers - you can't set their type to numeric because they aren't. There are ways for you to get Excel and PhpSpreadsheet to treat the first as a date, e.g. =DATE(2024, 4, 9).

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