How can I upload an excel file under YIIframe and save the read data to the database? How to do it.

Source: Internet
Author: User
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 '));

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.