I would like to write into a csv file using PHPEXCEL in the following format. The class in bold and a space after every class group.

But i have not been able to find a way to do it.
Here is what I could do.

I generate the data from an sql and loop thought it. Here is my code
$sql="SELECT * FROM table ORDER BY typeclass"; $query=mysql_query($sql); $check=''; $i=1; while($row=mysql_fetch_assoc($query)) { if($row['class']!=$check) { $objPHPExcel->getActiveSheet()->setCellValue('A'.$i,$row['Class']); $check=$row['class']; } $objPHPExcel->getActiveSheet()->setCellValue('B' .$i,$row['Name']); $objPHPExcel->getActiveSheet()->setCellValue('C' .$i,$row['score']); $i++; } Can anyone help me get the desired output.