I'm new with PHPExcel and very beginner with PHP. I reading alot of examples and but not finding any example that matches close to what I'm doing. This is what I would like my end result to look like.
So I was able to get PHP excel to extract everything from my SQL database and dumped everything row by row. But I would like the data to be nicely presentable in a sort of box/table/array/section as shown in the image. But in order to achieve the image above should I target each individual cell and have data automatically populated by SQL? Would then PHPexcel recognize that it needs to dump the next record onto the next section?
I was also given advice to try using fromArray()
method that can be used to set a whole block of cells in a single call from an array (such as a row read from a database). I am clueless how to get started with this.
If anyone can show me what the code should look like using these methods that would be greatly appreciated.
I managed to answer my question. Here a snippet of my code,
// SQl database connections
$db = mysql_connect("localhost", "IMC_COE2", "IMC123");
mysql_select_db("IMC_COE2",$db);
$sqlgroups="select client, team_name,support_team_prime,prime_comments,support_team_backup,backup_comments,escalation1,escalation1_comments,escalation2,escalation2_comments,escalation3,escalation3_comments,escalation4,escalation4_comments,note from tbl_address ORDER by team_name";
$resultgroups=mysql_query($sqlgroups);
$numrows=mysql_num_rows($resultgroups);
if ($numrows>0)
{
$count=2;
while($data=mysql_fetch_array($resultgroups))
{
$count+=1;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('C3', $data['client'])
->setCellValue('B2', $data['team_name'])
->setCellValue('C5', $data['support_team_prime'])
->setCellValue('D5', $data['prime_comments'])
->setCellValue('C6', $data['support_team_backup'])
->setCellValue('D6', $data['backup_comments'])
->setCellValue('C8', $data['escalation1'])
->setCellValue('D8', $data['escalation1_comments'])
->setCellValue('C9', $data['escalation2'])
->setCellValue('D9', $data['escalation2_comments'])
->setCellValue('C10', $data['escalation3'])
->setCellValue('D10', $data['escalation3_comments'])
->setCellValue('C11', $data['escalation4'])
->setCellValue('D11', $data['escalation4_comments'])
->setCellValue('B13', $data['note']);
}
}