php - How to get custom number formats in PHPSpreadsheet

I am trying to import an xlxs file that that some custom formats embedded within it. If I open the styles.xml file I can see the formats as follows:
When I am reading the data from these cells the custom formats aren't being applied, so I assume I need to do this manually withsetNumberFormat
- How can I read these custom format codes to format these values correctly?
Edit: Here is the code I am using to access the formatted value, slightly unusual as I am accessing PHPSpreadsheet classes via Laravel Excel.
foreach ($row->getCellIterator() as $cell) {
$value = (new Cell($cell))->getDelegate()->getFormattedValue();
dump($value);
}
Here is a dump of the results I get using this:
Item 10 should be01099391
rather than1099391
Answer
Solution:
You are probably looking for\PhpOffice\PhpSpreadsheet\Cell\Cell::getFormattedValue()
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: foreign key constraint is incorrectly formed laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.