Add all rows to excel spread sheet

Topics: User Forum
Jan 21, 2014 at 11:00 AM
Edited Jan 21, 2014 at 11:06 AM
I have form that posts to Mysql and all works fine for 1 row only. How would I get it to post all the new lines from the form?

My database looks like this:



id|number|user|date
34 - 45 - DJ - 23/01
35 - 46 - TR - 12/02
36 - 57 - PU - 08/01
$objPHPExcel->getActiveSheet()->SetCellValue('B2', $row['UNIT']);
$objPHPExcel->getActiveSheet()->SetCellValue('C2', $row['NUMBER']);
$objPHPExcel->getActiveSheet()->SetCellValue('D2', $row['USER']);
$objPHPExcel->getActiveSheet()->SetCellValue('E2', $row['DATE']);
Jan 22, 2014 at 2:58 PM
If you want to fill several lines in your Excel file, should you change coordinates.
$i=2;
$S=$objPHPExcel->getActiveSheet();
while($row=extractRow()){
$S->setCellValue('B'.$i, $row['UNIT'])
->setCellValue('C'.$i, $row['NUMBER']); // and all others keys (Alternative: Use fromArray either for a line, or for all of the data within the possibilities)
++$i;
}
extractRow() is replaced by the function that allows to fill $row
Jan 23, 2014 at 4:41 AM
Thank you @LWol, Legendary! working perfectly!