Yii::import('application.extensions.phpexcel1.JPhpExcel');
$xls = new JPhpExcel('UTF-8', false, 'My Test Sheet');
$xls->addArray($sheet_generation);
$xls->generateXML('my-test');
在控制器中:
$get_user_info=$model->userInfo();
###### Sheet generation
$sheet_generation=$model->sheetInfo($get_user_info,$month,$year);
在模特中: -
public function sheetInfo($user_info,$sel_month,$sel_year)
{
$cnt=0;
foreach($user_info as $key => $line) {
$cnt=$cnt+1;
$linearr = $line;
//$linearr['heading']='';
//$linearr['imagess']='';
//array_push($linearr, "apple", "raspberry");
//print_r($linearr); exit;
$p=$line['Place'];
$place=Sheet::getWorkin($p);
$userid=$line['id'];
// Total present days
$no_days=Sheet::getPresent($userid,$sel_month,$sel_year);
$disti=$line['Designation'];
//designation names...............
$designation=Sheet::detDesignationName($disti);
/// Department name display..............
$d=$line['Department'];
$depart=Sheet:: getDepartmantName($d);
// Holiday
$holiday=Sheet::getHolidayDat($sel_month,$sel_year);
$approval=2;
$leave_count=Sheet::getLeaveCount($userid,$sel_month,$sel_year,$approval);
###### sunday leave count
$sunday=Sheet::sunday_count($sel_month,$sel_year);
########saturday count
$sat_count=Sheet::saturday_count($sel_month,$sel_year);
$sat_sunday_count=Sheet::weekday_count($userid,$sel_month,$sel_year);
//$heading="Attendance Report January 2014";
//$linearr['heading']=Yii::app()->theme->baseUrl/images/."favicon.ico";
//$linearr['Sno']=$cnt;
$linearr['Place']=$place;
$linearr['Designation'] =$designation;
$linearr['Department'] =$depart;
$sum_present=$sum_present+$no_days; // sum of present days....................
$linearr['present'] =$no_days;
$linearr['holiday'] =$holiday;
$linearr['leave'] =$leave_count;
$linearr['weekoffice'] =$sat_sunday_count;
$linearr['lop'] =0;
$resarr[] = $linearr;
}
//print_r($resarr); exit;
return $resarr;
}