duncanhodgekiss / php-excel-reader

Automatically exported from code.google.com/p/php-excel-reader
0 stars 0 forks source link

Excel to Csv #153

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
my script don't work when i save the CSV file
please help me
<?php
require_once 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251'); // Set output Encoding.
$data->read('prodotti.xls');
error_reporting(E_ALL ^ E_NOTICE);

echo "<table border='1'>";
      //ciclo su tutte le righe
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
        echo "<tr>";
        //ciclo sulla prima colonna 
    for ($j = 1; $j <= 1; $j++) {
        echo "<td>".$data->sheets[0]['cells'][$i][$j]."</td>";
    }

            //ciclo sulla quarta colonna 
           for ($j = 4; $j <= 4; $j++) {
              echo "<td>".$data->sheets[0]['cells'][$i][$j]."</td>";

           }
    echo "</tr>";

}
echo "</table>";
                $csv = "";
                $rows = $data->rowcount();
                $cols = $data->colcount();
                $csv .= $data->raw($i, $j);
                   if($j == $cols - 1) {
                         $csv .= "\n";
                    } else {
                    $csv .= ",";
                            }  

        $handler = fopen("test1.csv", "w");
        fwrite($csv, $handler);
        fclose($handler); 
?>

Original issue reported on code.google.com by Raffaele...@gmail.com on 24 Aug 2012 at 10:36