I want to read an excel file and save the data in database. I tried this in pure PHP by using Spreadsheet_Excel_Reader it is working fine, but when I am using the same code in Zend Framework 2 it is not working. Giving no data...
2 Answers
You could export the excel file to a csv file (for example data.csv) and then you can do it with an SQL query:
LOAD DATA INFILE 'c:/tmp/data.csv'
INTO TABLE table_name
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
Check here for more information
3 Comments
BeDeveloper
Is this procedure can be done zend doctrine and .xls file can be uploaded or not
Wilt
@BeDeveloper Zend Framework 2 is a php framework so whatever you can do in php you can also do in ZF2. The question is more how much custom code you would have to write for this. You didn't talk about upload in your question at all, you should add such important information to your question next time (read also here). If those are files uploaded by clients and you will put the data it in your database you should be very careful since it is a perfect way for SQL injections.
BeDeveloper
Thanks alot i will be careful next time