You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2022. It is now read-only.
I have an excel file I'm trying to loop through. So far, I'm able to navigate to the worksheet I have to work on. I'm currently trying to loop through the data rows I have, and so far, this works for me:
foreach ($sheet->getRowIterator() as $row) {
$cells = $row->getCells();
foreach ($cells as $cell){
$cell_value = $cell->getValue();
echo "Cell Value = $cell_value<br>\n";
}
}
For the most part, this works a treat because most of the values are strings or numbers.
However, I've noticed that it doesn't work for date.
For example, I used print_r on the $cells variable just to double check and here's what I got:
The value is being read properly but as opposed to the other data rows I have, the value is a datetime object and not a string, and this presents an error.
I saw the setShouldFormatDate property in the documentation. While I'm able to use this with getValue() to get the formatted value in Excel (usually a dd-MMM-yy format like 11 APR 22), I'd like to be able to get this in the yyyy-mm-dd format.
Is there a way to do this within the library? Or do I just get the formatted value and then use PHP's built in function to convert the formatted date to my desired format?
Thank you.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have an excel file I'm trying to loop through. So far, I'm able to navigate to the worksheet I have to work on. I'm currently trying to loop through the data rows I have, and so far, this works for me:
For the most part, this works a treat because most of the values are strings or numbers.
However, I've noticed that it doesn't work for date.
For example, I used print_r on the
$cells
variable just to double check and here's what I got:The value is being read properly but as opposed to the other data rows I have, the value is a datetime object and not a string, and this presents an error.
I saw the
setShouldFormatDate
property in the documentation. While I'm able to use this withgetValue()
to get the formatted value in Excel (usually a dd-MMM-yy format like 11 APR 22), I'd like to be able to get this in theyyyy-mm-dd
format.Is there a way to do this within the library? Or do I just get the formatted value and then use PHP's built in function to convert the formatted date to my desired format?
Thank you.
The text was updated successfully, but these errors were encountered: