Ver Mensaje Individual
  #4 (permalink)  
Antiguo 13/12/2010, 12:14
areslepra
 
Fecha de Ingreso: diciembre-2010
Ubicación: Rosario, Santa Fe
Mensajes: 326
Antigüedad: 13 años, 5 meses
Puntos: 13
Respuesta: ayuda con salto de linea en php csv

Prueba así:

<?php
//*crear el csv
$csv_end = "\n";
$csv_sep = ";";
$csv_file = "data.csv";
$csv="";
//*
require_once 'CompoundDocument.inc.php';
require_once 'BiffWorkbook.inc.php';

$fileName = 'data.xls';
if (!is_readable ($fileName)) die ('Cannot read ' . $fileName);

$doc = new CompoundDocument ('utf-8');
$doc->parse (file_get_contents ($fileName));
$wb = new BiffWorkbook ($doc);
$wb->parse ();
foreach ($wb->sheets as $sheetName => $sheet)
{
'<h1>' . $sheetName . '</h1>';
'<table cellspacing = "0">';
for ($row = 0; $row < $sheet->rows (); $row ++)
{
'<tr>';
for ($col = 0; $col < $sheet->cols (); $col ++)
{
if (!isset ($sheet->cells [$row][$col])) continue;
$cell = $sheet->cells [$row][$col];

'<td style = "' . $cell->style->css () . '" rowspan = "' . $cell->rowspan . '" colspan = "' . $cell->colspan . '">';
is_null ($cell->value) ? '&nbsp;' : $cell->value;

///aqui es el prioblema ojala alguien me oriente


$csv.=$cell->value.$csv_sep;
'</td>';
}
$csv.=$csv_end;
'</tr>';
}
'</table>';
}
//creando el csv
if (!$handle = fopen($csv_file, "w")) {
echo "Cannot open file";
exit;
}
if (fwrite($handle, utf8_decode($csv)) === FALSE) {
echo "Cannot write to file";
exit;
}
fclose($handle);
?>