add export CSV to ANC grand livre

This commit is contained in:
Dany De Bontridder 2011-11-17 14:20:15 +00:00
parent 30f962432d
commit dfe59ee4e7
6 changed files with 183 additions and 2 deletions

View file

@ -229,4 +229,43 @@ class Impress
return true;
}
}
/**
* with the handle of a successull query, echo each row into CSV and
* send it directly
* @param type $array of data
* @param type $aheader double array, each item of the array contains
* a key type (num) and a key title
*/
static function array_to_csv($array,$aheader)
{
$seq="";
for ($i=0;$i<count($i);$i++)
{
echo '"'.$aheader[$i]['title'].'"';
$seq=";";
}
printf("\n\r");
$seq="";
// fetch all the rows
for ($i=0;$i<count($array);$i++)
{
$row=$array[$i];
$sep2="";
// for each rows, for each value
for ($e=0;$e<count($row);$e++)
{
switch ($aheader[$e]['type'])
{
case 'num':
echo nb($row[$e]).$sep2;
break;
default:
echo '"'.$row[$e].'"'.$sep2;
}
$sep2=";";
}
printf("\n\r");
}
}
}