exit;
}
+ public static function wescogroups()
+ {
+ CubeIT_Library::PHPExcel();
+ $reader = new PHPExcel_Reader_Excel2007();
+ $file = '/home/wesco/groups.xlsx';
+ if (!file_exists($file)) {
+ die(':(');
+ }
+ $xlsx = $reader->load('/home/wesco/groups.xlsx');
+
+ ob_end_clean();
+ $allgroups = [];
+ foreach ($xlsx->getAllSheets() as $s) {
+ if ($s->getTitle() === 'Lexique' || $s->getSheetState() !== PHPExcel_Worksheet::SHEETSTATE_VISIBLE) {
+ continue;
+ }
+ $groups = [];
+ $subgroups = [];
+ foreach ($s->getRowIterator() as $row) {
+ $rowIndex = $row->getRowIndex();
+ foreach ($row->getCellIterator() as $cell) {
+ $v = trim($cell->getValue());
+ $colIndex = PHPExcel_Cell::columnIndexFromString($cell->getColumn());
+
+ if (isset($groups[$colIndex])) {
+ $groupname = $groups[$colIndex];
+ } else {
+ $groupname = '';
+ }
+
+ if (isset($subgroups[$colIndex])) {
+ $subgroupname = $subgroups[$colIndex];
+ } else {
+ $subgroupname = '';
+ }
+
+ if (!$v) {
+ continue;
+ }
+ if ($cell->getMergeRange()) {
+
+ $e = explode(':', $cell->getMergeRange(), 2);
+ $start = PHPExcel_Cell::columnIndexFromString(substr($e[0], 0, 1));
+ $end = PHPExcel_Cell::columnIndexFromString(substr($e[1], 0, 1));
+
+ for ($i = $start; $i <= $end; $i++) {
+ $groups[$i] = $v;
+ }
+ } else if (preg_match('/^(\d{1,5})$/', $v, $matches)) {
+ $grouplabel = $s->getTitle() . ' - ' . $groupname . ' - ' . $subgroupname;
+ if (!isset($allgroups[$grouplabel])) {
+ $allgroups[$grouplabel] = [];
+ }
+ $allgroups[$grouplabel][] = $v;
+ } else {
+ $subgroups[$colIndex] = $v;
+ }
+ }
+ }
+
+ }
+
+ $res = [];
+ foreach ($allgroups as $k => $allgroup) {
+ $res[$k] = array_unique($allgroup);
+ }
+
+ $p = new PHPExcel();
+ $s = $p->getActiveSheet();
+ $s->setTitle('Groupes');
+ $s->setCellValueByColumnAndRow(0, 1, 'Onglet');
+ $s->setCellValueByColumnAndRow(1, 1, 'Références');
+ $rowIndex = 2;
+ foreach ($res as $groupName => $references) {
+ $s->setCellValueByColumnAndRow(0, $rowIndex, $groupName);
+ foreach ($references as $k => $reference) {
+ $s->setCellValueByColumnAndRow(1 + $k, $rowIndex, $reference);
+ }
+ $rowIndex++;
+ }
+ $writer = new PHPExcel_Writer_Excel2007($p);
+ $writer->save('/home/wesco/groups1.xlsx');
+
+ exit;
+ }
+
}