PHPExcel_Writer_Excel5

// PHPExcel_Writer_Excel5
public function excelEmail($data = array(), $excel_header = array(), $expansion= array())
    {
        $output_info = array('file_name' => null, 'file_real_path' => null);
        if(empty($data)){
            return $output_info;
        }
        if(empty($excel_header)){
            $excel_header = array_keys($data[0]);
        }
        $obj_excel = new PHPExcel();
        /*Export 2007
        $obj_writer = new PHPExcel_Writer_Excel2007($obj_excel);
        $obj_writer->setOffice2003Compatibility(true);*/
        $obj_writer = new PHPExcel_Writer_Excel5($obj_excel);
        $obj_props = $obj_excel->getProperties();
        $title = isset($expansion['title']) ?: 'title IT Support';
        $subject = isset($expansion['subject']) ?: 'subject IT Support';
        $description = isset($expansion['description']) ?: 'description IT Support';
        $keywords = isset($expansion['keywords']) ?: 'keywords IT Support';
        $category = isset($expansion['category']) ?: 'category IT Support';

        $obj_props->setCreator("AGA IT")
            ->setTitle($title)
            ->setSubject($subject)
            ->setDescription($description)
            ->setKeywords($keywords)
            ->setCategory($category);
        $obj_excel->setActiveSheetIndex(0);
        $obj_activity_sheet = $obj_excel->getActiveSheet();
        $obj_activity_sheet->setTitle('Data');

        $this->drawRow($obj_activity_sheet, $excel_header, 1);
        $row_index = 2;

        foreach ($data as $key => $value)
        {
            $this->drawRow($obj_activity_sheet, $value, $row_index);
            $row_index++;
        }
        $file_name = $title.'_'.date('Y-m-d H:i:s').'.xls';
        $output_excel_path = DOWNLOAD_PATH . 'email'. DIRECTORY_SEPARATOR .date('Y') . DIRECTORY_SEPARATOR . $file_name;
        $obj_writer->save($output_excel_path);
        $output_info['file_name'] = $file_name;
        $output_info['file_real_path'] = $output_excel_path;
        return $output_info;
    }

你可能感兴趣的:(php)