How to convert xls file into csv file using php or LAMP, Look at simple example to convert excel to csv file using php on linux server.
You can download reader.php file from http://sourceforge.net/projects/phpexcelreader/
<?php
require_once 'Excel/reader.php';
$excel = new Spreadsheet_Excel_Reader();
$excel->setOutputEncoding('CP1251');
$excel->read('b.xls');
$x=1;
$sep = ",";
ob_start();
while($x<=$excel->sheets[0]['numRows']) {
$y=1;
$row="";
while($y<=$excel->sheets[0]['numCols']) {
$cell = isset($excel->sheets[0]['cells'][$x][$y]) ? $excel->sheets[0]['cells'][$x][$y] : '';
$row.=($row=="")?"\"".$cell."\"":"".$sep."\"".$cell."\"";
$y++;
}
echo $row."\n";
$x++;
}
$fp = fopen("data.csv",'w');
fwrite($fp,ob_get_contents());
fclose($fp);
ob_end_clean();
?>
You can download reader.php file from http://sourceforge.net/projects/phpexcelreader/
This is a very nice script thanks
ReplyDelete