From be1ee3c5307d9b2a142df00209380be9aeeffcf9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 21 Jan 2013 10:11:35 -0800 Subject: [PATCH] Fix Maniphest Excel export for tasks with descriptions beginning with "=" Summary: Fixes T2369. If you create a task with a description like `= Header =`, the Excel writer interprets it as a formula. Explicitly set the cell types to strings to avoid this. Test Plan: Exported a task with the description `=1,`; no exception after this patch. Reviewers: btrahan, chad, vrana Reviewed By: chad CC: aran Maniphest Tasks: T2369 Differential Revision: https://secure.phabricator.com/D4567 --- .../maniphest/controller/ManiphestExportController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/applications/maniphest/controller/ManiphestExportController.php b/src/applications/maniphest/controller/ManiphestExportController.php index a28407df56..591e8ff310 100644 --- a/src/applications/maniphest/controller/ManiphestExportController.php +++ b/src/applications/maniphest/controller/ManiphestExportController.php @@ -16,6 +16,7 @@ final class ManiphestExportController extends ManiphestController { * @phutil-external-symbol class PHPExcel * @phutil-external-symbol class PHPExcel_IOFactory * @phutil-external-symbol class PHPExcel_Style_NumberFormat + * @phutil-external-symbol class PHPExcel_Cell_DataType */ public function processRequest() { $request = $this->getRequest(); @@ -43,6 +44,9 @@ final class ManiphestExportController extends ManiphestController { return id(new AphrontDialogResponse())->setDialog($dialog); } + // TODO: PHPExcel has a dependency on the PHP zip extension. We should test + // for that here, since it fatals if we don't have the ZipArchive class. + $query = id(new PhabricatorSearchQuery())->loadOneWhere( 'queryKey = %s', $this->key); @@ -78,7 +82,6 @@ final class ManiphestExportController extends ManiphestController { $handles += $project_handles; $workbook = new PHPExcel(); - $sheet = $workbook->setActiveSheetIndex(0); $sheet->setTitle('Tasks'); @@ -168,7 +171,9 @@ final class ManiphestExportController extends ManiphestController { foreach ($rows as $row => $cols) { foreach ($cols as $col => $spec) { $cell_name = $this->col($col).($row + 1); - $sheet->setCellValue($cell_name, $spec); + $sheet + ->setCellValue($cell_name, $spec, $return_cell = true) + ->setDataType(PHPExcel_Cell_DataType::TYPE_STRING); if ($row == 0) { $sheet->getStyle($cell_name)->applyFromArray($header_format);