From c232da764084c247aee0d29e0ef74e759a674b38 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 13 Sep 2019 08:01:19 +0000 Subject: [PATCH] done #3040 @1 --- inc/commons/class.common.tools.php | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 332589ed7..b73abc571 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -1358,4 +1358,42 @@ class commonTools return $fname; } + + public static function xlsxToJson($args) + { + global $core; + $res = commonPage::barre(); + $res .= commonPage::tMain(); + $res .= commonPage::bh(); + $res .= '
'; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= '
' . __('Convertir un xlsx en json') . '
' . __('Charger un fichier excel') . '
' . $core->typo->BoutonOK(__('Convertion')) . '
'; + $res .= '
'; + $res .= ''; + $res .= commonPage::bf(); + $res .= commonPage::bMain(); + return $res; + } + + public static function convertXlsxToJson($args) + { + new PHPExcel(); + + $reader = new PHPExcel_Reader_Excel2007(); + $xls = $reader->load($_FILES['file']['tmp_name']); + + $res = []; + foreach ($xls->getAllSheets() as $sheet) { + $res[$sheet->getTitle()]=$sheet->toArray(); + } + + ob_end_clean(); + + header('Content-Type: application/json'); + die(json_encode($res)); + } } -- 2.39.5