From 8f077bdf8651c1d2f9033206d14c93c1d14e81da Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Wed, 18 Dec 2019 06:43:26 +1100 Subject: [PATCH] Support MS Excel for Diacritic Characters when exporting a report to CSV --- CRM/Report/Utils/Report.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CRM/Report/Utils/Report.php b/CRM/Report/Utils/Report.php index f575d1f063..276ef7fe6b 100644 --- a/CRM/Report/Utils/Report.php +++ b/CRM/Report/Utils/Report.php @@ -212,6 +212,10 @@ WHERE inst.report_id = %1"; //Force a download and name the file using the current timestamp. $datetime = date('Ymd-Gi', $_SERVER['REQUEST_TIME']); CRM_Utils_System::setHttpHeader('Content-Disposition', 'attachment; filename=Report_' . $datetime . '.csv'); + // Output UTF BOM so that MS Excel copes with diacritics. This is recommended as + // the Windows variant but is tested with MS Excel for Mac (Office 365 v 16.31) + // and it continues to work on Libre Office, Numbers, Notes etc. + echo "\xEF\xBB\xBF"; echo self::makeCsv($form, $rows); CRM_Utils_System::civiExit(); } -- 2.25.1