I have multiple array and i want to write each array into each tab of excels sheets using PHP -


i have following array. want write array in excel sheets using php.

 try{     $client = new soapclient(wsdl_url, array('cache_wsdl' => wsdl_cache, 'trace' => true, 'features' => soap_single_element_arrays, 'proxy_host' => soap_proxy_host, 'proxy_port' => soap_proxy_port));     $client->__setlocation(wsdl_endpoint_url);     $result = $client->maximiselostprospectdecision();     //print_r($result);     //exit;     if (!empty($result->lostprospect->lostprospectrow))      {       foreach ($result->lostprospect->lostprospectrow $prospect)       {            $fields   =   array();           foreach($prospect $key=>$prospect_details)           {              $fields[]=$prospect_details;            }                              }            } } 

<?php   ini_set('max_execution_time',0); error_reporting('all'); ini_set('display_errors','on'); ini_set('memory_limit', '51200m'); $email      = $argv[2]; $instance   = $argv[1];   require_once ('classes/phpexcel.php'); require_once ('classes/phpexcel/iofactory.php');  $_request['instance']   = $instance;  require_once dirname(__file__).'/../../boot/bootstrap.php';  $date_from      =   date('y-m-d', mktime(0, 0, 0, date("m"), date("d")-7, date("y"))); $date_to            =   date('y-m-d', mktime(0, 0, 0, date("m"), date("d")-1, date("y"))); $date=date('f y'); $objphpexcel = new phpexcel();  $allprospectarray=array();  try{     $client = new soapclient(wsdl_url, array('cache_wsdl' => wsdl_cache, 'trace' => true, 'features' => soap_single_element_arrays, 'proxy_host' => soap_proxy_host, 'proxy_port' => soap_proxy_port));      $client->__setlocation(wsdl_endpoint_url);            //*********** keep funation /.p file in array dynmaiclly call **************//          $allprospectarray['decision'] ='maximiselostprospectdecision';         $allprospectarray['duplicate']= 'maximiselostprospectduplicate';         $allprospectarray['exitingcustomer']= 'maximiselostprospectexisting_customer';         $allprospectarray['moveorclose']= 'maximiselostprospectmove_or_close';         $allprospectarray['noneed']= 'maximiselostprospectno_need';         $allprospectarray['optout']= 'maximiselostprospectopt_out';         $allprospectarray['ownerchange']= 'maximiselostprospectowner_change';         $allprospectarray['poordata']= 'maximiselostprospectpoor_data';         $allprospectarray['price']= 'maximiselostprospectprice';         $allprospectarray['servicequality']= 'maximiselostprospectservice_quality';             $tabcount=count($allprospectarray);          $tabindex=0;                foreach ($allprospectarray $key=> $resultval)              {                      $result=array() ; //*********** initialise array ************//                     $result=$client->$resultval(); //********* progress function/.p file call //                     if (!empty($result->lostprospect->lostprospectrow))                      {                           $fields=array();                           $datacontent=$result->lostprospect->lostprospectrow;                           foreach ($datacontent $prospect)                           {                              $fields[]=(array) $prospect;                           }                             $filename='';                             $filename='tmp/activity_csv/'.$key.'.xls';                             chmod($filename,0777);                             $tabindex++;                             $objphpexcel->setactivesheetindex(0);                                $objphpexcel->getactivesheet()->settitle($key);                             $objphpexcel->getactivesheet()->fromarray($fields, null, 'a1');                             $objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel5');                             $objwriter->save(str_replace('maximiselostprospectbackup.php',$filename, __file__));                      }                }   //************ types prospects end//      }      catch (exception $e) {             echo "failed data. error: ".$e->getmessage();             print_r($e);             exit;             }             ?> 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -