How to make horizontal table phpexcel? -
$objphpexcel->getactivesheet()->setcellvalue('a1', "no"); $objphpexcel->getactivesheet()->setcellvalue('b1', "name"); $objphpexcel->getactivesheet()->setcellvalue('c1', "age"); $objphpexcel->getactivesheet()->setcellvalue('d1', "job"); $stylearray = array('borders' => array('allborders' => array('style' => phpexcel_style_border::border_thick,'color' => array('argb' => '808080'),),),); $objphpexcel->getactivesheet()->getstyle('a1:d1')->applyfromarray($stylearray); $sql="select * cuba"; $query_c = mysqli_query($conn,$sql); $n=2; while($row_result=mysqli_fetch_assoc($query_c)){ $objphpexcel->getactivesheet()->setcellvalue('a'.$n,$row_result['id']); $objphpexcel->getactivesheet()->setcellvalue('b'.$n,$row_result['name']); $objphpexcel->getactivesheet()->setcellvalue('c'.$n,$row_result['age']); $objphpexcel->getactivesheet()->setcellvalue('d'.$n,$row_result['job']); $n++; } $objphpexcel->getactivesheet()->getcolumndimension('a')->setautosize(true); $objphpexcel->getactivesheet()->getcolumndimension('b')->setautosize(true); $objphpexcel->getactivesheet()->getcolumndimension('c')->setautosize(true); $objphpexcel->getactivesheet()->getcolumndimension('d')->setautosize(true);
this code table i've done want change horizontal.
the table desire want horizontal table
as you're using $n
row number; make column instead, , store each data item in rows 1-4:
$n='b'; while($row_result=mysqli_fetch_assoc($query_c)){ $objphpexcel->getactivesheet()->setcellvalue($n.'1',$row_result['id']); $objphpexcel->getactivesheet()->setcellvalue($n.'2',$row_result['name']); $objphpexcel->getactivesheet()->setcellvalue($n.'3',$row_result['age']); $objphpexcel->getactivesheet()->setcellvalue($n.'4',$row_result['job']); $n++; }
wiki
Comments
Post a Comment