Excel PHP Vertical Alignment not working? -


all i'm trying here make b16 cell align top. i've wrote code reason when open in excel align bottom still know why is? set in //set up area.

//excel transfer     $myfile=fopen("data/bi_spo.txt","r") or exit("can't open file!");     $spo = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/bi_cont.txt","r") or exit("can't open file!");     $cont = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/bi_site.txt","r") or exit("can't open file!");     $site = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/bi_job.txt","r") or exit("can't open file!");     $job = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/ob_des.txt","r") or exit("can't open file!");     $des1 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/ob_act.txt","r") or exit("can't open file!");     $act1 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/ob_date.txt","r") or exit("can't open file!");     $date1 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gp_des.txt","r") or exit("can't open file!");     $des2 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gp_act.txt","r") or exit("can't open file!");     $act2 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gp_date.txt","r") or exit("can't open file!");     $date2 = fgets($myfile);     fclose($myfile);          $myfile=fopen("data/fgr_des.txt","r") or exit("can't open file!");     $des3 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/fgr_act.txt","r") or exit("can't open file!");     $act3 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/fgr_date.txt","r") or exit("can't open file!");     $date3 = fgets($myfile);     fclose($myfile);          $myfile=fopen("data/gip1_radio1.txt","r") or exit("can't open file!");     $p1radio1 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gip1_radio2.txt","r") or exit("can't open file!");     $p1radio2 = fgets($myfile);     fclose($myfile);          $myfile=fopen("data/gip1_radio3.txt","r") or exit("can't open file!");     $p1radio3 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gip1_radio4.txt","r") or exit("can't open file!");     $p1radio4 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gip1_radio5.txt","r") or exit("can't open file!");     $p1radio5 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gip2_radio1.txt","r") or exit("can't open file!");     $p2radio1 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gip2_radio2.txt","r") or exit("can't open file!");     $p2radio2 = fgets($myfile);     fclose($myfile);          $myfile=fopen("data/gip2_radio3.txt","r") or exit("can't open file!");     $p2radio3 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gip2_radio4.txt","r") or exit("can't open file!");     $p2radio4 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gip2_radio5.txt","r") or exit("can't open file!");     $p2radio5 = fgets($myfile);     fclose($myfile);      $myfile=fopen("data/gip3_add.txt","r") or exit("can't open file!");     $add = fgets($myfile);     fclose($myfile);          $myfile=fopen("data/cb_name.txt","r") or exit("can't open file!");     $name = fgets($myfile);     fclose($myfile);          $myfile=fopen("data/cb_title.txt","r") or exit("can't open file!");     $title = fgets($myfile);     fclose($myfile);          $myfile=fopen("data/cb_date.txt","r") or exit("can't open file!");     $date = fgets($myfile);     fclose($myfile);      include_once 'php/phpexcel.php';      $objphpexcel = new phpexcel();     $activesheet = $objphpexcel->getactivesheet();     $objphpexcel->getactivesheet()->settitle('senior managers site tour');     $objphpexcel->getactivesheet()->getcolumndimension('a')->setwidth(5);      $stylearray = array(         'borders' => array(             'allborders' => array(                 'style' => phpexcel_style_border::border_thin                 )             )         );        //set     $activesheet->setcellvalue('e1','senior managers site tour');     $objphpexcel->getactivesheet()->getstyle('a1:n70')->applyfromarray($stylearray);     $objphpexcel->getactivesheet()->mergecells('a1:a70');     $objphpexcel->getactivesheet()->mergecells('n1:n70');      $styleverticalalign = array(         'alignment' => array(             'horizontal' => phpexcel_style_alignment::vertical_top,         )     );      $objphpexcel->getactivesheet()->getstyle('b13')->applyfromarray($styleverticalalign);      //logo & title     $objphpexcel->getactivesheet()->mergecells('b1:d4');     $objphpexcel->getactivesheet()->mergecells('e1:m4');     $objphpexcel->getactivesheet()->mergecells('b5:m5');      $objdrawing = new phpexcel_worksheet_drawing();     $objdrawing->setname('murphys logo');     $objdrawing->setpath('images/logoexcel.png');     $objdrawing->setcoordinates('b1');     $objdrawing->setworksheet($objphpexcel->getactivesheet());      $titlearray = array(         'font'  => array(             'bold'  => true,             'size'  => 32,         ));      $styletitlealign = array(         'alignment' => array(             'horizontal' => phpexcel_style_alignment::horizontal_center,         )     );      $objphpexcel->getactivesheet()->getstyle('e1')->applyfromarray($titlearray);     $objphpexcel->getactivesheet()->getstyle('e1')->applyfromarray($styletitlealign);      //basic information     $objphpexcel->getactivesheet()->mergecells('b6:d6');     $objphpexcel->getactivesheet()->mergecells('e6:g6');     $objphpexcel->getactivesheet()->mergecells('h6:j6');     $objphpexcel->getactivesheet()->mergecells('k6:m6');     $objphpexcel->getactivesheet()->mergecells('b7:d7');     $objphpexcel->getactivesheet()->mergecells('e7:m7');     $objphpexcel->getactivesheet()->mergecells('b8:d8');     $objphpexcel->getactivesheet()->mergecells('e8:m8');     $objphpexcel->getactivesheet()->mergecells('b9:m10');      $activesheet->setcellvalue('b6','site / project / object:');     $activesheet->setcellvalue('e6',$spo);     $activesheet->setcellvalue('h6','contract number:');     $activesheet->setcellvalue('k6',$cont);     $activesheet->setcellvalue('b7','site manager:');     $activesheet->setcellvalue('e7',$site);     $activesheet->setcellvalue('b8','job / task description:');     $activesheet->setcellvalue('e8',$job);      //observation     $objphpexcel->getactivesheet()->mergecells('b11:m11');     $objphpexcel->getactivesheet()->mergecells('b12:e12');     $objphpexcel->getactivesheet()->mergecells('f12:i12');     $objphpexcel->getactivesheet()->mergecells('j12:m12');     $objphpexcel->getactivesheet()->mergecells('b13:e17');     $objphpexcel->getactivesheet()->mergecells('f13:i17');     $objphpexcel->getactivesheet()->mergecells('j13:m17');     $objphpexcel->getactivesheet()->mergecells('b18:m19');        $activesheet->setcellvalue('b11','observation (areas improvement can made).');     $activesheet->setcellvalue('b12','breif description:');     $activesheet->setcellvalue('b13',$des1);     $activesheet->setcellvalue('f12','agreed action:');     $activesheet->setcellvalue('f13',$act1);     $activesheet->setcellvalue('j12','close date:');     $activesheet->setcellvalue('j13',$date1);      $objphpexcel->getactivesheet()->getstyle('b11')->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setrgb('d6d6d6');      //good practices     $objphpexcel->getactivesheet()->mergecells('b20:m20');     $objphpexcel->getactivesheet()->mergecells('b21:e21');     $objphpexcel->getactivesheet()->mergecells('f21:i21');     $objphpexcel->getactivesheet()->mergecells('j21:m21');     $objphpexcel->getactivesheet()->mergecells('b22:e26');     $objphpexcel->getactivesheet()->mergecells('f22:i26');     $objphpexcel->getactivesheet()->mergecells('j22:m26');     $objphpexcel->getactivesheet()->mergecells('b27:m28');      $activesheet->setcellvalue('b20','good practices (commendable acts , actions, improvements, innovations etc).');     $activesheet->setcellvalue('b21','breif description:');     $activesheet->setcellvalue('b22',$des2);     $activesheet->setcellvalue('f21','agreed action:');     $activesheet->setcellvalue('f22',$act2);     $activesheet->setcellvalue('j21','close date:');     $activesheet->setcellvalue('j22',$date2);      $objphpexcel->getactivesheet()->getstyle('b20')->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setrgb('d6d6d6');      //feedback given & received     $objphpexcel->getactivesheet()->mergecells('b29:m29');     $objphpexcel->getactivesheet()->mergecells('b30:e30');     $objphpexcel->getactivesheet()->mergecells('f30:i30');     $objphpexcel->getactivesheet()->mergecells('j30:m30');     $objphpexcel->getactivesheet()->mergecells('b31:e35');     $objphpexcel->getactivesheet()->mergecells('f31:i35');     $objphpexcel->getactivesheet()->mergecells('j31:m35');     $objphpexcel->getactivesheet()->mergecells('b36:m37');      $activesheet->setcellvalue('b29','feedback given & received');     $activesheet->setcellvalue('b30','breif description:');     $activesheet->setcellvalue('b31',$des3);     $activesheet->setcellvalue('f30','agreed action:');     $activesheet->setcellvalue('f31',$act3);     $activesheet->setcellvalue('j30','close date:');     $activesheet->setcellvalue('j31',$date3);      $objphpexcel->getactivesheet()->getstyle('b29')->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setrgb('d6d6d6');      //general impression     $objphpexcel->getactivesheet()->mergecells('b38:m38');     $objphpexcel->getactivesheet()->mergecells('b39:g39');     $objphpexcel->getactivesheet()->mergecells('h39:m39');     $objphpexcel->getactivesheet()->mergecells('b40:g40');     $objphpexcel->getactivesheet()->mergecells('h40:m40');     $objphpexcel->getactivesheet()->mergecells('b41:m41');     $objphpexcel->getactivesheet()->mergecells('b42:k42');     $objphpexcel->getactivesheet()->mergecells('l42:m42');     $objphpexcel->getactivesheet()->mergecells('b43:k43');     $objphpexcel->getactivesheet()->mergecells('l43:m43');     $objphpexcel->getactivesheet()->mergecells('b44:k44');     $objphpexcel->getactivesheet()->mergecells('l44:m44');     $objphpexcel->getactivesheet()->mergecells('b45:k45');     $objphpexcel->getactivesheet()->mergecells('l45:m45');     $objphpexcel->getactivesheet()->mergecells('b46:k46');     $objphpexcel->getactivesheet()->mergecells('l46:m46');     $objphpexcel->getactivesheet()->mergecells('b47:m47');      $objphpexcel->getactivesheet()->mergecells('b48:k48');     $objphpexcel->getactivesheet()->mergecells('l48:m48');     $objphpexcel->getactivesheet()->mergecells('b49:k49');     $objphpexcel->getactivesheet()->mergecells('l49:m49');     $objphpexcel->getactivesheet()->mergecells('b50:k50');     $objphpexcel->getactivesheet()->mergecells('l50:m50');     $objphpexcel->getactivesheet()->mergecells('b51:k51');     $objphpexcel->getactivesheet()->mergecells('l51:m51');     $objphpexcel->getactivesheet()->mergecells('b52:k52');     $objphpexcel->getactivesheet()->mergecells('l52:m52');     $objphpexcel->getactivesheet()->mergecells('b53:m54');      $activesheet->setcellvalue('b38','general impression');     $activesheet->setcellvalue('b39','1 = no evidence / poor / no understanding');     $activesheet->setcellvalue('h39','2 = evidence / understanding / not consistent');     $activesheet->setcellvalue('b40','3 = requirements in place / basic unerstanding');     $activesheet->setcellvalue('h40','4 = detailed understanding / more minimum standards');      $objphpexcel->getactivesheet()->getstyle('b38')->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setrgb('d6d6d6');      $activesheet->setcellvalue('b41','culture');     $activesheet->setcellvalue('b42','is cdp obvious - said / did boards; feedback stations; posters?:');     $activesheet->setcellvalue('l42',$p1radio1);     $activesheet->setcellvalue('b43','are there speak coaches on site?');     $activesheet->setcellvalue('l43',$p1radio2);     $activesheet->setcellvalue('b44','are focus leader meetings happening?:');     $activesheet->setcellvalue('l44',$p1radio3);     $activesheet->setcellvalue('b45','mention mental tools, people understand them?:');     $activesheet->setcellvalue('l45',$p1radio4);     $activesheet->setcellvalue('b46','ask "never harm" means teams:');     $activesheet->setcellvalue('l46',$p1radio5);      $objphpexcel->getactivesheet()->getstyle('b41')->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setrgb('d6d6d6');      $activesheet->setcellvalue('b47','system');     $activesheet->setcellvalue('b48','are first impressions good, site signage, induction etc?:');     $activesheet->setcellvalue('l48',$p2radio1);     $activesheet->setcellvalue('b49','is site tidy, laid out etc?:');     $activesheet->setcellvalue('l49',$p2radio2);     $activesheet->setcellvalue('b50','are morning briefings / daily risk assessment carried out?:');     $activesheet->setcellvalue('l50',$p2radio3);     $activesheet->setcellvalue('b51','have team been briefed & signed onto rams?:');     $activesheet->setcellvalue('l51',$p2radio4);     $activesheet->setcellvalue('b52','ask if there change in work activity i.e. not in rams?:');     $activesheet->setcellvalue('l52',$p2radio5);      $objphpexcel->getactivesheet()->getstyle('b47')->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setrgb('d6d6d6');      //comments     $objphpexcel->getactivesheet()->mergecells('b55:m55');     $objphpexcel->getactivesheet()->mergecells('b56:m63');     $objphpexcel->getactivesheet()->mergecells('b64:m65');      $activesheet->setcellvalue('b55','additional comments:');     $activesheet->setcellvalue('b56',$add);      $objphpexcel->getactivesheet()->getstyle('b55')->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setrgb('d6d6d6');      //completed     $objphpexcel->getactivesheet()->mergecells('b66:m66');     $objphpexcel->getactivesheet()->mergecells('b67:c67');     $objphpexcel->getactivesheet()->mergecells('d67:g67');     $objphpexcel->getactivesheet()->mergecells('h67:i67');     $objphpexcel->getactivesheet()->mergecells('j67:m67');     $objphpexcel->getactivesheet()->mergecells('b68:c68');     $objphpexcel->getactivesheet()->mergecells('d68:g68');     $objphpexcel->getactivesheet()->mergecells('h68:m68');     $objphpexcel->getactivesheet()->mergecells('b69:m70');      $activesheet->setcellvalue('b66','completed by');     $activesheet->setcellvalue('b67','name:');     $activesheet->setcellvalue('d67',$name);     $activesheet->setcellvalue('h67','title:');     $activesheet->setcellvalue('j67',$title);     $activesheet->setcellvalue('b68','date:');     $activesheet->setcellvalue('bd68',$date);      $objphpexcel->getactivesheet()->getstyle('b66')->getfill()->setfilltype(phpexcel_style_fill::fill_solid)->getstartcolor()->setrgb('d6d6d6');      $objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel5');       $objwriter->save('senior managers site tour.xls'); 

try this:

$objphpexcel->getactivesheet()->getstyle('b13') ->getalignment()->setvertical(phpexcel_style_alignment::vertical_top); 

have @ docs class phpexcel_style_alignment


Comments