Cara kerja dari converter ini sangat sederhana, Library membaca File excel, kemudian file excel tersebut dimapping sesuai dengan header tabel dan nama field yang ada didalam tabel. kemudian record tersebut dimasukkan kedalam tabel.
Cekidot aja deh contohnya dibawah ini, semoga bermanfaat :
require_once 'Excel2Psql/excel2psql.php';
$excel_file = "testing_koperasi.xls";
$excel2psql = new Excel2PgSQL($excel_file);
//$excel2psql ->setConvertArea( '$A$1:$E$5' );
$excel2psql ->setRowStart(1);
$excel2psql ->setColStart('A');
$excel2psql ->setColMapping(
array('1'=>'field_1',
'2'=>'field_2','3'=>'field_3',
'4'=>'field_4','5'=>'field_5',
'6'=>'field_6','7'=>'field_7',
'8'=>'field_8','9'=>'field_9',
'10'=>'field_10','11'=>'field_11',
'12'=>'field_12','13'=>'field_13',
'14'=>'field_14','15'=>'field_15',
'16'=>'field_16','17'=>'field_17',
'18'=>'field_18','19'=>'field_19',
'20'=>'field_20','21'=>'field_21',
'22'=>'field_22','23'=>'field_23','24'=>'field_24')
);
$excel2psql ->connectDB ('localhost','nama_user_db','pass_user_db','nama_db','nama_tabel');
$excel2psql ->injectData();
if($excel2psql ){
echo "Improt data berhasil";
}else{
echo "Improt data gagal";
}
Klik excel2pgsql.rar untuk source lengkapnya...