How can I upload an excel file under YIIframe and save the read data to the database? How can this problem be solved? Please... I'm so anxious. I'm not familiar with this framework, but I don't know much about it... phpexcelphpexcel. you can design a database and use phpexcel to read it and insert it. For details, see how to upload an excel file in phpexcel YIIframe, read data and save it to the database? How can this problem be solved? Please...
I'm in a hurry. I'm not familiar with this framework, so many of them won't ....
------ Solution --------------------
Phpexcel
Phpexcel
After the database is designed to be read with phpexcel, you can insert it. For more information, see phpexcel documentation.
------ Solution --------------------
1. download phpexcel
2. decompress the package to/protected/extesions/phpexcel.
3. Call
Public function actionExcel (){
$ Excel_path = dirname (_ FILE _). '/.../../files/users.xlsx ';
Yii: import ('ext. phpexcel. Classes .*');
// Disable automatic yii loading
Spl_autoload_unregister (array ('yibase', 'autoload '));
Include 'phpexcel/IOFactory. php ';
$ ObjPHPExcel = PHPExcel_IOFactory: load ($ excel_path );
$ SheetData = $ objPHPExcel-> getActiveSheet ()-> toArray (null, true );
Var_dump ($ sheetData );
// Resume automatic loading of yii
Spl_autoload_register (array ('yibase', 'autoload '));
}