From: vincent@cubedesigners.com Date: Wed, 24 Aug 2022 13:33:27 +0000 (+0000) Subject: wait #5414 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b26ba6cb7a9ea6632513b6feadb2d27a67b067c7;p=cubeextranet.git wait #5414 --- diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 4cf3be912..8297bab99 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -1384,76 +1384,13 @@ class commonTools public static function xlsxToJson($args) { - global $core; - $res = commonPage::barre(); - $res .= commonPage::tMain(); - $res .= commonPage::bh(); - $res .= '
'; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= '
' . __('Convertir un xlsx en json') . '
' . __('Charger un fichier excel') . '
Organisation des données
Format de sortie
' . $core->typo->BoutonOK(__('Convertion')) . '
'; - $res .= '
'; - $res .= ''; - $res .= commonPage::bf(); - $res .= commonPage::bMain(); - return $res; + header('Location: https://toolbox.fluidbook.com/opentools/excel2json', true, 308); } public static function convertXlsxToJson($args) { - require_once ROOT . '/inc/ws/Util/class.ws.util.php'; - $f = $_POST['dataorg']; - $res = wsUtil::$f($_FILES['file']['tmp_name']); - $json = json_encode($res); - ob_end_clean(); - - 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) - { - new PHPExcel(); - - $reader = new PHPExcel_Reader_Excel2007(); - $xls = $reader->load($_FILES['file']['tmp_name']); - - $res = []; - foreach ($xls->getAllSheets() as $sheet) { - $lines = $sheet->toArray(); - foreach ($lines as $line) { - if (null === $line[0]) { - continue; - } - $k = trim($line[0]); - if (!$k) { - continue; - } - $v = trim($line[1]); - $res[$k] = $v; - } - break; - } - - ob_end_clean(); - - header('Content-Type: application/json'); - die(json_encode($res)); + header('Location: https://toolbox.fluidbook.com/opentools/doexcel2json', true, 308); } public static function excelTranslationM($args)