From d2dfd7ddb0904db7dc41cd40fb4807bf4c3609e6 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 23 Jan 2018 16:29:54 +0200 Subject: [PATCH] excel export: supporting address --- application/Espo/Core/Export/Xlsx.php | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/application/Espo/Core/Export/Xlsx.php b/application/Espo/Core/Export/Xlsx.php index 9294587d6d..26be562e0c 100644 --- a/application/Espo/Core/Export/Xlsx.php +++ b/application/Espo/Core/Export/Xlsx.php @@ -386,6 +386,40 @@ class Xlsx extends \Espo\Core\Injectable } $sheet->setCellValue("$col$rowNumber", implode(', ', $nameList)); } + } else if ($type == 'address') { + $value = ''; + if (!empty($row[$name . 'Street'])) { + $value = $value .= $row[$name.'Street']; + } + if (!empty($row[$name.'City']) || !empty($row[$name.'State']) || !empty($row[$name.'PostalCode'])) { + if ($value) { + $value .= "\n"; + } + if (!empty($row[$name.'City'])) { + $value .= $row[$name.'City']; + if ( + !empty($row[$name.'State']) || !empty($row[$name.'PostalCode']) + ) { + $value .= ', '; + } + } + if (!empty($row[$name.'State'])) { + $value .= $row[$name.'State']; + if (!empty($row[$name.'PostalCode'])) { + $value .= ' '; + } + } + if (!empty($row[$name.'PostalCode'])) { + $value .= $row[$name.'PostalCode']; + } + } + if (!empty($row[$name.'Country'])) { + if ($value) { + $value .= "\n"; + } + $value .= $row[$name.'Country']; + } + $sheet->setCellValue("$col$rowNumber", $value); } else { if (array_key_exists($name, $row)) { $sheet->setCellValue("$col$rowNumber", $row[$name]);