Exemple #1
0
 public static function import()
 {
     $data = array();
     if ($_FILES['upload']['tmp_name']) {
         $objPHPExcel = PHPExcel_IOFactory::load($_FILES['upload']['tmp_name']);
         $sheet = $objPHPExcel->setActiveSheetIndex(0);
         $cols = 1;
         while ($sheet->getCell(Impexp::dfe($cols) . '2')->getValue() != NULL) {
             //$data[0][]=$sheet->getCell(Impexp::dfe($i).'1')->getValue();
             $cols++;
         }
         $ii = 3;
         while ($sheet->getCell('A' . ($ii + 1))->getValue() != NULL) {
             $partname = $sheet->getCell('B' . ($ii + 1))->getValue();
             $size = $sheet->getCell('C' . ($ii + 1))->getValue();
             if ($size == '') {
                 $size = 'universal';
             }
             foreach (Price::$c as $i => $item) {
                 if ($item != 'name' && $item != 'size') {
                     if ($size == 'universal') {
                         $data[$partname]['universal'][$item] = $sheet->getCell(Impexp::dfe($i) . ($ii + 1))->getValue();
                         $data[$partname]['nosize'][$item] = $sheet->getCell(Impexp::dfe($i) . ($ii + 1))->getValue();
                     } else {
                         $data[$partname][$size][$item] = $sheet->getCell(Impexp::dfe($i) . ($ii + 1))->getValue();
                     }
                 }
             }
             $ii++;
         }
         Price::setList($data);
         //print '<pre>';print_r($data);die;
     }
 }
Exemple #2
0
 public static function import()
 {
     $data = array();
     if ($_FILES['upload']['tmp_name']) {
         $objPHPExcel = PHPExcel_IOFactory::load($_FILES['upload']['tmp_name']);
         $sheet = $objPHPExcel->setActiveSheetIndex(0);
         $cols = 0;
         while ($sheet->getCell(Impexp::dfe($cols) . '1')->getValue() != NULL) {
             //$data[0][]=$sheet->getCell(Impexp::dfe($i).'1')->getValue();
             $cols++;
         }
         $ii = 0;
         while ($sheet->getCell('A' . ($ii + 1))->getValue() != NULL) {
             for ($i = 0; $i < $cols; $i++) {
                 $data[$ii][$i] = $sheet->getCell(Impexp::dfe($i) . ($ii + 1))->getValue();
             }
             $ii++;
         }
         Impexp::setList($data);
         /*print '<pre>';
         		print_r($data);
         		die;*/
     }
 }