protected function writeCell($value, $column, $row, $config) { // auto type if (!isset($config['type']) || $config['type'] === null) { $this->sheet->setCellValueByColumnAndRow($column, $row, $value); } elseif ($config['type'] === 'date') { if (!is_int($value)) { $timestamp = strtotime($value); } $this->sheet->SetCellValueByColumnAndRow($column, $row, \PHPExcel_Shared_Date::PHPToExcel($timestamp)); if (!isset($config['styles']['numberformat']['code'])) { $config['styles']['numberformat']['code'] = $this->defaultDateFormat; } } elseif ($config['type'] === 'url') { if (isset($config['label'])) { if ($config['label'] instanceof \Closure) { // NOTE: calculate label on top level $label = call_user_func($config['label']); } else { $label = $config['label']; } } else { $label = $value; } $urlValid = filter_var($value, FILTER_VALIDATE_URL) !== false; if (!$urlValid) { $label = ''; } $this->sheet->setCellValueByColumnAndRow($column, $row, $label); if ($urlValid) { $this->sheet->getCellByColumnAndRow($column, $row)->getHyperlink()->setUrl($value); } } else { $this->sheet->setCellValueExplicitByColumnAndRow($column, $row, $value, $config['type']); } if (isset($config['styles'])) { $this->sheet->getStyleByColumnAndRow($column, $row)->applyFromArray($config['styles']); } }