Closed gerritwitkamp closed 1 year ago
I'll add a dateFormatter() method where you can set your own date handler. I think this will be the best solution
Good question. I think it would be logical to fill the row in two cases:
setReadArea('a:f');
Excel::KEYS_FIRST_ROW
Done in v2.8.0
Hi,
I want all cell values to be strings, excepts dates values; they should be an instance of DateTime. Following the docs a date value is converted to a timestamp (integer), but that way I can't differentiate them from other integer cell values.
One way I could think of is extending the Excel class and override the formatDate method to return a DateTime instance. Or maybe I can identify a date value using the readRowsWithStyles?
Furthermore small question; can i force the row array to be as much as columns as the (first) headers row (filled with empty strings for example)? Used the following trick
foreach ($this->sheet->nextRow([], Excel::KEYS_ZERO_BASED) as $row) { yield array_replace(array_fill_keys(range(0, $this->nrOfCols), ''), array_map(fn($value) => $value instanceof \DateTime ? $value : (string) $value, $row)); }
Thanks in advance.