![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
13/12/2010, 12:05
|
| | Fecha de Ingreso: julio-2010
Mensajes: 34
Antigüedad: 14 años, 6 meses Puntos: 0 | |
Respuesta: ayuda con salto de linea en php csv Si amigo tines razon colocando el saltode linea ahora me bota asi
1;
2;
3;
4;
lo que yo estoy buscando esque muestre el csv
asi
1;3
2;4
este es mi escript leeo un excel y traigo la data de dos columnas
columna 1 valores 1,2
columna 2 valores 3,4
<?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) ? ' ' : $cell->value; ///aqui es el prioblema ojala alguien me oriente $csv.=$cell->value.$csv_sep.$csv_end;
'</td>';
}
'</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);
?> |