From 4f0273da8b2b4d74a6f8e8259e240700189c256d Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Mon, 27 Jun 2022 08:40:07 +0000 Subject: [PATCH] Spreadsheet adjustments. Wait #5051 @1.25 --- inc/ws/Controlleur/class.ws.services.php | 26 +++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index ea6242825..62a2cb1c3 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -1455,14 +1455,30 @@ class wsServices extends cubeFlashGateway // Look up the value by the column keys to ensure the correct order of values foreach (array_keys($column_headings) as $column_index => $column_key) { - $sheet->setCellValueByColumnAndRow($column_index, $current_row, $cart_item[$column_key]); $current_cell_style = $sheet->getStyleByColumnAndRow($column_index, $current_row); - if (in_array($column_key, ['PRIX HT', 'PRIX TTC'])) { - $current_cell_style->getNumberFormat()->setFormatCode($euro_currency_format); - } elseif (in_array($column_key, ['QTE', 'QTE MINI'])) { - $current_cell_style->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER); + switch($column_key) { + case 'EAN': // Ensure EAN doesn't contain commas (it's a number, not a string) + $EAN = str_replace(',', '', $cart_item[$column_key]); + $sheet->setCellValueByColumnAndRow($column_index, $current_row, $EAN); + $current_cell_style->getNumberFormat()->setFormatCode('#,##0'); // Comma separated, no decimals + break; + case 'REF': // Explicitly store REF as text in order to preserve leading zeros + $sheet->setCellValueExplicitByColumnAndRow($column_index, $current_row, $cart_item[$column_key], PHPExcel_Cell_DataType::TYPE_STRING); + break; + case 'PRIX HT': + case 'PRIX TTC': + $sheet->setCellValueByColumnAndRow($column_index, $current_row, $cart_item[$column_key]); + $current_cell_style->getNumberFormat()->setFormatCode($euro_currency_format); + break; + case 'QTE': + case 'QTE MINI': + $sheet->setCellValueByColumnAndRow($column_index, $current_row, $cart_item[$column_key]); + $current_cell_style->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER); + break; + default: + $sheet->setCellValueByColumnAndRow($column_index, $current_row, $cart_item[$column_key]); } } -- 2.39.5