user2720970
user2720970

Reputation: 294

PHPexcel Add rows from Mysql

I have a form that posts to mysql like this:

enter image description here

The First 2 entries ( ID and User ) need to go a specific Cell once:

$objPHPExcel->getActiveSheet()->SetCellValue('A1', $row['ID']);
$objPHPExcel->getActiveSheet()->SetCellValue('C1', $row['User']);

The others ( Date, Unit and Number ) need to post to the row from left to right.

Like this:

enter image description here

Upvotes: 0

Views: 422

Answers (1)

Naruto
Naruto

Reputation: 1200

//some code to get the data from mysql

//teller to know where to start in sql
$teller = 5;
foreach($yourarray as $row){
    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $teller, $row['ID']);
    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $teller, $row['User']); 
    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $teller, $row['Date']); 
    //D - Z?
    $teller++;
}

This what u want?

Upvotes: 1

Related Questions