-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[QUESTION]: How to disable cell value calculation when importing? #2253
Comments
Hey @numaquevedo the examples you are given are not being calculated. By default calculating formulas is disabled. The examples you give are how Excel internally stores dates and times. You'll have to use PhpSpreadsheets Date helper to convert them to a date time object. |
@patrickbrouwers Thank you very much. I found this link after posting the question and before reading your comment: #1832 |
I'd like to know how could I disable for a single cell and keep the others calculating.
Like this "vigencia_contrato_aditivo" is a formula, and this way is turning into a date. That's ok until here. But I also want to store the formula too. How do I make it? |
You might have to use onEachRow to have control over that and call the |
Carbon::instance(\PhpOffice\PhpSpreadsheet\Shared\Date:: excelToDateTimeObject($val)) This helped me a lot. Thank you!!! You don't need onEachRow . You can pass any value and it will transform it if date in excel. |
Prerequisites
Versions
Description
I am trying to import a basic xlsx file. I used the command to generate the import class and I am using
ToCollection
. I noticed that some of the values that are passed to thecollection()
method are already being calculated. Below are some of the steps I took to attempt to prevent this situation:Custom Value Binder
to attempt to keep the value as string, but the value being received there is already calculated.The values are being converted like this:
01/01/2019 (Date) -> 43466
9:00:00 AM -> 0.375
I am not sure how I can fix this. I have read the entire documentation and there is nothing that could suggest a way to remediate this problem.
Please advice.
Additional Information
The text was updated successfully, but these errors were encountered: