php - Uncaught Error: Call to undefined method PHPExcel::sheetNameExists() -


i'm getting error when try , generate excel document know error coming from?

fatal error: uncaught error: call undefined method phpexcel::sheetnameexists() in /public_html/docs/php/phpexcel/worksheet.php:835 stack trace: #0 /public_html/docs/php/phpexcel/worksheet.php(337): phpexcel_worksheet->settitle('worksheet', false) #1 /public_html/docs/php/phpexcel.php(108): phpexcel_worksheet->__construct(object(phpexcel)) #2 /public_html/docs/senddocument.php(33): phpexcel->__construct() #3 {main} thrown in /public_html/docs/php/phpexcel/worksheet.php on line 835

<?php //excel data     $spo = $_session["spo"];     $cont = $_session["contractnum"];     $site = $_session["siteman"];     $job = $_session["jtd"];     $obbrief = $_session["ob_des"];     $obagreed = $_session["ob_act"];     $obdate = $_session["date1"];     $gobrief = $_session["good_des"];     $goagreed = $_session["good_act"];     $godate = $_session["date2"];     $febrief = $_session["fe_des"];     $feagreed = $_session["fe_act"];     $fedate = $_session["date3"];     $q1 = '';     $q2 = '';     $q3 = '';     $q4 = '';     $q5 = '';     $q6 = '';     $q7 = '';     $q8 = '';     $q9 = '';     $q10 = '';     $add = $_session["addcom"];     $name = $_session["name"];     $title = $_session["title"];     $date = $_session["date4"];       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');     $objphpexcel->getactivesheet()->getstyle('b6:m68')->getalignment()->setvertical(phpexcel_style_alignment::vertical_top);      $titlearray = array(         'font'  => array(             'bold'  => true,             'size'  => 32,         ));      $styletitlealign = array(         'alignment' => array(             'horizontal' => phpexcel_style_alignment::horizontal_center,         )     );  //title     $objphpexcel->getactivesheet()->mergecells('b1:d4');     $objphpexcel->getactivesheet()->mergecells('e1:m4');     $objphpexcel->getactivesheet()->mergecells('b5:m5');      $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','brief description:');     $activesheet->setcellvalue('b13',$obbrief);     $activesheet->setcellvalue('f12','agreed action:');     $activesheet->setcellvalue('f13',$obagreed);     $activesheet->setcellvalue('j12','close date:');     $activesheet->setcellvalue('j13',$obdate);      $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','brief description:');     $activesheet->setcellvalue('b22',$gobrief);     $activesheet->setcellvalue('f21','agreed action:');     $activesheet->setcellvalue('f22',$goagreed);     $activesheet->setcellvalue('j21','close date:');     $activesheet->setcellvalue('j22',$godate);      $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','brief description:');     $activesheet->setcellvalue('b31',$febrief);     $activesheet->setcellvalue('f30','agreed action:');     $activesheet->setcellvalue('f31',$feagreed);     $activesheet->setcellvalue('j30','close date:');     $activesheet->setcellvalue('j31',$fedate);      $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',$q1);     $activesheet->setcellvalue('b43','are there speak coaches on site?');     $activesheet->setcellvalue('l43',$q2);     $activesheet->setcellvalue('b44','are focus leader meetings happening?:');     $activesheet->setcellvalue('l44',$q3);     $activesheet->setcellvalue('b45','mention mental tools, people understand them?:');     $activesheet->setcellvalue('l45',$q4);     $activesheet->setcellvalue('b46','ask "never harm" means teams:');     $activesheet->setcellvalue('l46',$q5);      $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',$q6);     $activesheet->setcellvalue('b49','is site tidy, laid out etc?:');     $activesheet->setcellvalue('l49',$q7);     $activesheet->setcellvalue('b50','are morning briefings / daily risk assessment carried out?:');     $activesheet->setcellvalue('l50',$q8);     $activesheet->setcellvalue('b51','have team been briefed & signed onto rams?:');     $activesheet->setcellvalue('l51',$q9);     $activesheet->setcellvalue('b52','ask if there change in work activity i.e. not in rams?:');     $activesheet->setcellvalue('l52',$q10);      $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('d68',$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'); ?> 

seems using wrong phpexcel version , need re-install library

see [this answer] more details.

investigation

after code follow-through via phpexcel repository on github following observations can made:

when phpexcel instantiated, it's constructor builds worksheets array 1 worksheet.

// initialise worksheet collection , add 1 worksheet $this->worksheetcollection = array(); $this->worksheetcollection[] = new phpexcel_worksheet($this); 

notice worksheet, when instantiated, gets phpexcel instance constructor. , object assigned worksheets property parent:

public function __construct(phpexcel $pparent = null, $ptitle = 'worksheet') {     // set parent , title     $this->parent = $pparent;     ... 

now, see settitle method called worksheet:

$objphpexcel->getactivesheet()->settitle('senior managers site tour'); 

inside settitle there's following code:

if ($this->parent) {     // there such sheet name?     if ($this->parent->sheetnameexists($pvalue)) {         ... 

and here exception thrown.

we can see method present in phpexcel code , can see parent correctly recognized member of class. conclusion wrong version of phpexcel.php used. missing function has been added in v. 1.8.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -