RE: [PHP] import XLS sheet into DB
| From: | Simcha | Date: | Sun, 17 Aug 2008 07:53:58 +0000 |
| Subject: | RE: [PHP] import XLS sheet into DB | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278238@lists.php.net to get a copy of this message | ||
Try using:
http://sourceforge.net/docman/display_doc.php?docid=22092&group_id=99160
I have never used it, but it looks very straightforward. Docs are here:
http://sourceforge.net/docman/display_doc.php?docid=22092&group_id=99160
code should be something like this: (for mysql, based on docs)
<?php
include('reader.php');
//Make an instance of the class:
$xl_reader = new Spreadsheet_Excel_Reader();
$xl_reader->read("filename.xls");
$data = $xl_reader->sheets[0]['cells'];
Foreach($cells as $c){
foreach($c as $cd) $row[] = "\"".$cd."\"";
$row = implode(",", $row);
mysql_query("insert into
table values(".$row.")");
}
?>
-----Original Message-----
From: Jason Pruim [mailto:japruim@raoset.com]
Sent: Friday, August 15, 2008 12:29 PM
To: Alain R.
Cc: php-general@lists.php.net
Subject: Re: [PHP] import XLS sheet into DB
On Aug 15, 2008, at 4:29 AM, Alain R. wrote:
> Hi,
>
> I would like to import content of an XLS sheet into a PostgreSQL DB
> (table).
>
> How can i do that ?
> thanks a lot,
>
> A.
Alain,
I haven't done it with PostgreSQL... But assuming it's not far from
MySQL just save the excel file as a csv, or a tab separated file and
import that. If you find away to import a strict xls file let me know,
I have a project that could really benefit from that :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@raoset.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.138 / Virus Database: 270.6.3/1612 - Release Date: 14/08/2008
18:03