CodeIgniter Forums
How to read data from Excel & insert into table using CI? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to read data from Excel & insert into table using CI? (/showthread.php?tid=25869)

Pages: 1 2


How to read data from Excel & insert into table using CI? - El Forum - 12-28-2009

[eluser]suba[/eluser]
Hi every one,
I have some data in Excel sheet.
Now I want to upload my excel data into table using CI.
So do you have any idea or any reference manual for CI?
please advice me.
Thanks..


How to read data from Excel & insert into table using CI? - El Forum - 12-28-2009

[eluser]richthegeek[/eluser]
It depends...

If the file is in the old (.xls) format, and you have access to the server, and can install packages: install Perl (probably pre-installed) and use http://www.topology.org/linux/xls.html OR just use http://search.cpan.org/dist/Spreadsheet-ParseExcel-Simple/

If its in .xls but you can't install packages, you need to have the file exported to .csv and parse using file() and preg_match() (google it!)

If its in the new format (.xlsx), and your server matches the requirements (PECL zip/zlib) you can extract using PHP's zip functions http://www.php.net/manual/en/book.zip.php

The simplest to program is the export to CSV and going from there - the rest is a case of moving the .xls(x) file to CSV first.


How to read data from Excel & insert into table using CI? - El Forum - 12-28-2009

[eluser]suba[/eluser]
Hi Thank you so much.

one more question.
Now my xls sheet has saved as to xml format.
So now how to retrieve data from xml format and import into table.

NOTE:
using MS office 2007, I changed xlsx format to xml format.
sample xml file:
<Row ss:AutoFitHeight="0">
<Cell ss:StyleID="s81"><Data ss:Type="String">NAME OF THE PERSON</Data><NamedCell
ss:Name="_FilterDatabase"/></Cell>
<Cell ss:StyleID="s81"><Data ss:Type="String">PERSON ID</Data></Cell>
<Cell ss:StyleID="s81"><Data ss:Type="String">ADDRESS OF PERSON</Data></Cell>
<Cell ss:StyleID="s62"><Data ss:Type="Number">PHONE NUMBER</Data></Cell>
</Row>


How to read data from Excel & insert into table using CI? - El Forum - 12-28-2009

[eluser]richthegeek[/eluser]
SimpleXML, PHPQuery, or plain old PXML libaries will all get what you need. If you already know CSS selectors and/or jQuery, PHPQuery will be the easiest to pick up.


How to read data from Excel & insert into table using CI? - El Forum - 12-28-2009

[eluser]suba[/eluser]
Thanks..
I got it.
Thanks..


How to read data from Excel & insert into table using CI? - El Forum - 12-29-2009

[eluser]umefarooq[/eluser]
better way to import your excel file is first convert it to csv file because csv file has no complex header and really easy to parse, here is csv file reader library for CI and really helpful to import data from csv file just read the comment in lib file you will under stand how to import data to database really easy, find out here.

http://codeigniter.com/wiki/CSVReader/


How to read data from Excel & insert into table using CI? - El Forum - 01-03-2010

[eluser]suba[/eluser]
Hi,
Thanks so much..


How to read data from Excel & insert into table using CI? - El Forum - 08-26-2014

[eluser]sparky672[/eluser]
[quote author="umefarooq" date="1262071736"].... find out here.

http://codeigniter.com/wiki/CSVReader/[/quote]

The link is dead. Thanks.


How to read data from Excel & insert into table using CI? - El Forum - 08-26-2014

[eluser]CroNiX[/eluser]
So just use php. http://php.net/manual/en/function.fgetcsv.php


How to read data from Excel & insert into table using CI? - El Forum - 09-02-2014

[eluser]mikemiller[/eluser]
You could try PHPExcel - very capable library that can be used to read excel files (including xlsx)

https://phpexcel.codeplex.com