Im doing a project in PHP(Codeigniter) and the project should be able to import excel files data and store in database. What is the best way to import and export excel files in PHP.
-
1have a look at this http://stackoverflow.com/questions/15446796/csv-import-library-for-codeigniter – Dave Aug 12 '16 at 08:31
-
1Excel != csv...... – Aug 12 '16 at 09:00
-
Thank you @Dagon. I know they are not same.What i was trying to say was we can read excel files using fgetcsv function. – lcshobin Aug 12 '16 at 09:04
-
No you can't. Unless you use Excel's save as csv – Aug 12 '16 at 09:05
-
Use PHPExcel library it have everything that you will need. Tried and Tested. – Kapil Yadav Nov 11 '16 at 06:58
3 Answers
fgetcsv is for .cvs (comma separated values) files.
Excel stores a lot more information than a *.cvs file, e.g. formulas, styles, etc. You would have to convert your file to *.cvs and doing so you would loss a lot of additional functionally. *.cvs files are fast to parse field data but if you need anything beyond that you probably want to go with PHP Excel.

- 187
- 12
PHPExcel would be my choice, their library and documentation is more informed and larger, with what seemingly looks like an easier usage.
The only drawback I can see is the lack of ease of use with the PhP function.

- 689
- 1
- 4
- 16
Actually, there are no technical dis-advantages of using PHP's inbuilt functions. In fact, libraries are developed upon such in-built functions. However, there are many advantages of using a well developed and maintained library like PHPExcel:
- You don't need to re-invent the wheel. What you need is almost developed. You just need to invest time in customization.
- Library is open-source. Many developers would have contributed their time and efforts. It is more likely to have robustness and stability.
- Standards would be followed. It makes it easier to maintain.
- Any individual might not be aware of all the possible issues. Some generic issues might have already been resolved. This again saves your time. Such libraries are easily scalable.
You can think of reverse of above mentioned points as dis-advantages of using in-built functions.

- 2,300
- 1
- 17
- 32
-
Can Downvoter please explain the reason of down voting the answer? Please share thoughts. – Bhavik Shah Aug 12 '16 at 09:13