Data to Excell

Topics: User Forum
Dec 11, 2011 at 11:50 PM
Edited Dec 11, 2011 at 11:55 PM

I try to find a way to put some data to my excellsheet. I don't know how to loop the numbers and characters

 

I have got the next script:

 if(isset($_POST['submit_verwerken']))
  {
 $qry = "
  SELECT
   *
  FROM
   mw_urenreg
  INNER JOIN
   mw_gegevens
  ON
   mw_urenreg.gegevens_id=mw_gegevens.mw_gegevens_persnr
  INNER JOIN
   mw_urenreg_status
  ON
   mw_urenreg_status.mw_urenreg_status_id=mw_urenreg.status
  WHERE
   mw_urenreg.status='2'
  AND
   mw_urenreg.time_end<='".$time_end."'
 ";
   
  }
$sql = mysql_query($qry);  
 if($sql === false)
 {
   echo (" Er gaat iets mis in de query (".$qry .")".mysql_error());
 }
 else
 {
  while($list = mysql_fetch_array($sql))
  {
  $id, $medewerker, $datum, $uurloon, $uren_totaal, $salaris_totaal
  }
 }


      
to this:

// Headers
//echo date('H:i:s') . " Add some data\n";
$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', 'id-urenadmin')
            ->setCellValue('B1', 'Naam medewerker')
            ->setCellValue('C1', 'Datum')
            ->setCellValue('D1', 'Uurloon')
            ->setCellValue('E1', 'Totaal aantal uren')
            ->setCellValue('F1', 'Totaal Bedrag');
// Data in loop
$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A2', '$id')
            ->setCellValue('B2', '$medewerker')
            ->setCellValue('C2', '$datum')
            ->setCellValue('D2', '$uurloon')
            ->setCellValue('E2', '$totaal_uren')
            ->setCellValue('F2', '$totaal_salaris');

Dec 13, 2011 at 7:30 PM

its pretty simple, this is what i did:

 

//open the file

$file = fopen("../EDI.txt","r");
//insert the file into array
while(!feof($file))
{

$myarray[]=fgetcsv($file);

}
 $l=9; // I started it in the 9th row, template required it


echo date('H:i:s') . " Add some data\n";


foreach ($myarray as $value){

$fname=$value[0].", ".$value[1];$objPHPExcel->setActiveSheetIndex(0)       

    ->setCellValue("A".$l,$fname)           

->setCellValue("H$l", $value[2])           

->setCellValue("C$l", $value[3])           

->setCellValue("D$l", $value[4])           

->setCellValue("E$l", $value[5])         

  ->setCellValue("F$l", $value[6]);                         

$l++;           }