RE: import XLS sheet into DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx] 
Sent: Friday, August 15, 2008 12:29 PM
To: Alain R.
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  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@xxxxxxxxxx





-- 
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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux