1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

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
This commit is contained in:
epriestley 2013-01-21 10:11:35 -08:00
parent 73f63158a8
commit be1ee3c530

View file

@ -16,6 +16,7 @@ final class ManiphestExportController extends ManiphestController {
* @phutil-external-symbol class PHPExcel * @phutil-external-symbol class PHPExcel
* @phutil-external-symbol class PHPExcel_IOFactory * @phutil-external-symbol class PHPExcel_IOFactory
* @phutil-external-symbol class PHPExcel_Style_NumberFormat * @phutil-external-symbol class PHPExcel_Style_NumberFormat
* @phutil-external-symbol class PHPExcel_Cell_DataType
*/ */
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
@ -43,6 +44,9 @@ final class ManiphestExportController extends ManiphestController {
return id(new AphrontDialogResponse())->setDialog($dialog); 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( $query = id(new PhabricatorSearchQuery())->loadOneWhere(
'queryKey = %s', 'queryKey = %s',
$this->key); $this->key);
@ -78,7 +82,6 @@ final class ManiphestExportController extends ManiphestController {
$handles += $project_handles; $handles += $project_handles;
$workbook = new PHPExcel(); $workbook = new PHPExcel();
$sheet = $workbook->setActiveSheetIndex(0); $sheet = $workbook->setActiveSheetIndex(0);
$sheet->setTitle('Tasks'); $sheet->setTitle('Tasks');
@ -168,7 +171,9 @@ final class ManiphestExportController extends ManiphestController {
foreach ($rows as $row => $cols) { foreach ($rows as $row => $cols) {
foreach ($cols as $col => $spec) { foreach ($cols as $col => $spec) {
$cell_name = $this->col($col).($row + 1); $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) { if ($row == 0) {
$sheet->getStyle($cell_name)->applyFromArray($header_format); $sheet->getStyle($cell_name)->applyFromArray($header_format);