S
S
sv82016-05-23 20:37:36
excel
sv8, 2016-05-23 20:37:36

How to format date with maatwebsite/excel in Laravel?

Good afternoon everyone!
Problem: There is an Excel document, one of the columns of which is a date in an unknown format.
It is necessary to organize data import using the maatwebsite/excel package.
Now , if the date in the column is given in the format dd.MM.yyyy - maatwebsite/excel turns the values ​​(dates) into numbers, for example: 23563.0. In the documentation, this problem is solved by explicitly specifying the date format: the date format in the document may vary. Tell me , please, how can I organize automatic date formatting from X format to Y format using maatwebsite / excel in Laravel?$reader->formatDates(true, 'Y-m-d');

$reader->filter('chunk')
    ->load($this->getImportFile())
    ->chunk(200, function($rowCollection) {
        $rows = $rowCollection->all();
        dd($rows);
        });

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrzej Wielski, 2016-05-23
@wielski

The answer is simple - do not use automatic import.
Process the fields yourself, create an array with import rules for each field. Thus, you can customize at least the filling of complex links.
So it will be much more universal, believe me.

D
Denis, 2015-08-13
@foma24

The question is removed, for some reason the connection was not created.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question