MySQL PHP is not exporting large data to Excel -


i want export excel file mysql table name personen has 35 columns , contain around 950+ records, if export around 300 rows using limit in query generates excel when try export 500 rows , more produces in 0 byte excel file enter image description here

here code

ini_set('memory_limit','1024m'); require_once 'phpexcel.php';   require_once 'db_config.inc.php'; // create new phpexcel object   $objphpexcel = new phpexcel();    // set properties   $objphpexcel->getproperties()->setcreator("maarten balliauw")   ->setlastmodifiedby("habib ul haque")   ->settitle("office 2007 xlsx test document")   ->setsubject("office 2007 xlsx test document")   ->setdescription("test document office 2007 xlsx, generated using php classes.")   ->setkeywords("office 2007 openxml php")   ->setcategory("test result file");      $rows=1;  //this hard coded *non dynamic* cell formatting     $objphpexcel->getactivesheet()->getcolumndimension('a')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('b')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('c')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('d')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('e')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('f')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('g')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('h')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('i')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('j')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('k')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('l')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('m')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('n')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('o')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('p')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('q')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('r')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('s')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('t')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('u')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('v')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('w')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('x')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('y')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('z')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('aa')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('ab')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('ac')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('ad')->setwidth(5);       $objphpexcel->getactivesheet()->getcolumndimension('ae')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('af')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('ag')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('ah')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('ai')->setwidth(5);     $objphpexcel->getactivesheet()->getcolumndimension('aj')->setwidth(5);     $objphpexcel->getactivesheet()->getsheetview()->setzoomscale(85);      $objphpexcel->setactivesheetindex(0)             ->setcellvalue('a'.($rows+0),'persoon-id')             ->setcellvalue('b'.($rows+0),'aanspreking')             ->setcellvalue('c'.($rows+0),'voornaam')             ->setcellvalue('d'.($rows+0),'naam')             ->setcellvalue('e'.($rows+0),'fonetisch')             ->setcellvalue('f'.($rows+0),'extra naam')             ->setcellvalue('g'.($rows+0),'adres1')             ->setcellvalue('h'.($rows+0),'adres2')             ->setcellvalue('i'.($rows+0),'postcode')             ->setcellvalue('j'.($rows+0),'plaats')             ->setcellvalue('k'.($rows+0),'land')             ->setcellvalue('l'.($rows+0),'taal')             ->setcellvalue('m'.($rows+0),'tel1')             ->setcellvalue('n'.($rows+0),'tel1-nota')             ->setcellvalue('o'.($rows+0),'fax1')             ->setcellvalue('p'.($rows+0),'fax1-nota')             ->setcellvalue('q'.($rows+0),'email1')             ->setcellvalue('r'.($rows+0),'email1-nota')             ->setcellvalue('s'.($rows+0),'tel2')             ->setcellvalue('t'.($rows+0),'tel2-nota')             ->setcellvalue('u'.($rows+0),'fax2')             ->setcellvalue('v'.($rows+0),'fax2-nota')             ->setcellvalue('w'.($rows+0),'email2')             ->setcellvalue('x'.($rows+0),'email2-nota')             ->setcellvalue('y'.($rows+0),'nota-1')             ->setcellvalue('z'.($rows+0),'nota-2')             ->setcellvalue('aa'.($rows+0),'mailing')             ->setcellvalue('ab'.($rows+0),'datum-invoer')             ->setcellvalue('ac'.($rows+0),'datum-laatste-wijziging')             ->setcellvalue('ad'.($rows+0),'extra1')             ->setcellvalue('ae'.($rows+0),'extra2')             ->setcellvalue('af'.($rows+0),'extra3')             ->setcellvalue('ag'.($rows+0),'oude publieksbestand-id')             ->setcellvalue('ah'.($rows+0),'vantabel')             ->setcellvalue('ai'.($rows+0),'correct addres')             ->setcellvalue('aj'.($rows+0),'codes');     //  sql database connections    /* $db = mysql_connect("localhost", "imc_coe2", "imc123");       mysql_select_db("imc_coe2",$db);   */     $mysqli= new mysqli(db_host,db_user,db_pass,db_name) or die("couldnt connect database".mysqli_connect_error());     $sql="select * personen";       $result=$mysqli->query($sql) or die($mysqli->error);            if ($result->num_rows>0)           {            $i=1;             while($data=$result->fetch_array(mysqli_assoc))               {              $query="select personselectiecodes.selectiecode personselectiecodes join personen on(personen.personid=personselectiecodes.personid) personselectiecodes.personid=".$data['personid']."";         $res=$mysqli->query($query) or die($mysqli->error);          $codes=array();             while ($row1=$res->fetch_array(mysqli_assoc))              {                 if ($row1['selectiecode']!="")                  {                     $codes[]=$row1['selectiecode'];                 }             }         $str=implode(';',$codes);                 //this section actual data import fromt sql database *dont touch*                 $objphpexcel->setactivesheetindex(0)                                           ->setcellvalue('a'.($rows+$i), $data['personid']) //this give cell c2.                              ->setcellvalue('b'.($rows+$i), $data['salutation']) // give cell b2                              ->setcellvalue('c'.($rows+$i), $data['lastname']) //this give c5                              ->setcellvalue('d'.($rows+$i), $data['firstname'])  // give d5                             ->setcellvalue('e'.($rows+$i), $data['phonetical'])  //this give c6                             ->setcellvalue('f'.($rows+$i), $data['extraname']) //this give d6 etc...                               ->setcellvalue('g'.($rows+$i), $data['address1'])                             ->setcellvalue('h'.($rows+$i), $data['address2'])                             ->setcellvalue('i'.($rows+$i), $data['postalcode'])                             ->setcellvalue('j'.($rows+$i), $data['area'])                             ->setcellvalue('k'.($rows+$i), $data['country'])                             ->setcellvalue('l'.($rows+$i), $data['language'])                             ->setcellvalue('m'.($rows+$i), $data['tel1'])                             ->setcellvalue('n'.($rows+$i), $data['tel1note'])                             ->setcellvalue('o'.($rows+$i), $data['fax1'])                             ->setcellvalue('p'.($rows+$i), $data['fax1note'])                             ->setcellvalue('q'.($rows+$i), $data['email1'])                             ->setcellvalue('r'.($rows+$i), $data['email1note'])                             ->setcellvalue('s'.($rows+$i), $data['tel2'])                             ->setcellvalue('t'.($rows+$i), $data['tel2note'])                             ->setcellvalue('u'.($rows+$i), $data['fax2'])                             ->setcellvalue('v'.($rows+$i), $data['fax2note'])                             ->setcellvalue('w'.($rows+$i), $data['email2'])                             ->setcellvalue('x'.($rows+$i), $data['email2note'])                             ->setcellvalue('y'.($rows+$i), $data['note1'])                             ->setcellvalue('z'.($rows+$i), $data['note2'])                             ->setcellvalue('aa'.($rows+$i), $data['mailing'])                             ->setcellvalue('ab'.($rows+$i), $data['inputdate'])                             ->setcellvalue('ac'.($rows+$i), $data['datelastmodified'])                             ->setcellvalue('ad'.($rows+$i), $data['extra1'])                             ->setcellvalue('ae'.($rows+$i), $data['extra2'])                             ->setcellvalue('af'.($rows+$i), $data['extra3'])                             ->setcellvalue('ag'.($rows+$i), $data['oldpublicfileid'])                             ->setcellvalue('ah'.($rows+$i), $data['fromtable'])                             ->setcellvalue('ai'.($rows+$i), $data['correctaddress'])                              ->setcellvalue('aj'.($rows+$i),$str);                 $i++;                 }           }         // rename sheet       $objphpexcel->getactivesheet()->settitle('directory tool full dump');      // set active sheet index first sheet, excel opens first sheet     $objphpexcel->setactivesheetindex(0);      // redirect output client’s web browser (excel5)      ob_end_clean();      $objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel5');       header('content-type: application/vnd.ms-excel');      header('content-disposition: attachment;filename="export-directory tool.xls"');      header('cache-control: max-age=0');      $objwriter->save('php://output');       exit;       ?>  

desire output

there in 1 of cell values phpexcel believes formula, ie string value beginning =; isn't valid excel formula, otherwise phpexcel wouldn't failing when trying evaluate formula.

you'll need identify value database, , ensure use setcellvalueexplicit() method tell phpexcel should treated string , not formula


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -