先生成Excel模板,然后导入Excel数据到MysqL,每条数据对应图片上传到阿里云
PHP
PHPStorm.
PHPOffice\PHPSpreadsheet\Spreadsheet;
PHPOffice\PHPSpreadsheet\Writer\Xlsx;
ProductBatchModel
add(
(!->_validate(,'add'
= = = =
(((['excel_file'],'.'),1)<>'xlsx' ->addError('excel_file','请上传xlsx格式的Excel文件'
= ('com/',['excel_file'
= \PHPOffice\PHPSpreadsheet\IOFactory::createReader('Xlsx' ->setReadDataOnly( = ->load(DIR_UPLOAD.[1]);
= -> = ->getHighestRow();
= ->getHighestColumn();
= \PHPOffice\PHPSpreadsheet\Cell\Coordinate::columnIndexFromString();
= - 1 ( <= 0 ->addError('Excel','Excel表格中没有数据'
= =
( = 2; <= ; ++
= ->getCellByColumnAndRow(1,)-> (( ->addError('model_no'.,'第'..'行产品型号为空' } = ->getProductByModel( (( [] = ;
分类**********************************
= ->getCellByColumnAndRow(2,)-> (( ->addError('category_name'.,'第'..'行分类名为空' } = ->getCategoryIdByName( (( ->addError('category_name'.,'第'..'行分类名不存在'