From: vincent@cubedesigners.com Date: Mon, 30 Nov 2020 11:56:42 +0000 (+0000) Subject: wait #4101 @0.9 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=68a54010cf61b35c1953130c90cb8bc665d83ed1;p=cubeextranet.git wait #4101 @0.9 --- diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 5aec2d6bc..cf8542de4 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -1389,12 +1389,17 @@ class commonTools $res = commonPage::barre(); $res .= commonPage::tMain(); $res .= commonPage::bh(); - $res .= '
'; + $res .= ''; $res .= ''; $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; $res .= '
' . __('Convertir un xlsx en json') . '
' . __('Charger un fichier excel') . '
' . $core->typo->BoutonOK(__('Convertion')) . '
' . __('Charger un fichier excel') . '
Organisation des données
Format de sortie
' . $core->typo->BoutonOK(__('Convertion')) . '
'; $res .= '
'; $res .= ''; @@ -1403,32 +1408,23 @@ class commonTools 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)); - } - public static function convertXlsxToColumnKeysJson($args) + public static function convertXlsxToJson($args) { require_once ROOT . '/inc/ws/Util/class.ws.util.php'; - $res = wsUtil::excelToArrayKeyVars($_FILES['file']['tmp_name']); - + $f = $_POST['dataorg']; + $res = wsUtil::$f($_FILES['file']['tmp_name']); + $json = json_encode($res); ob_end_clean(); - header('Content-Type: application/json'); - die(json_encode($res)); + + if ($_POST['format'] === 'json') { + header('Content-Type: application/json'); + die($json); + } else if ($_POST['format'] === 'js') { + header('Content-Type: application/javascript'); + header('Content-Disposition: attachment; filename="data.js"'); + die('var DATA=' . $json . ';'); + } } public static function convertXlsxToKeyValueJson($args)