PHPExcel

	public function excel_get(){
		$this->check_login();

		$file = FCPATH . 'uploads' . DIRECTORY_SEPARATOR . 'Members.xls';
		$file_url = base_url() . 'uploads/Members.xls';
		
		// Initiate cache
		$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
		$cacheSettings = array( 'memoryCacheSize' => '32MB');
		PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
		$objPHPExcel = new PHPExcel();

		//Create $worksheet object to save data
		$worksheet = $objPHPExcel->setActiveSheetIndex(0);
		$rowN = 1;
		$columnN = 0;

		$headers = array(
			'ID', 
			'姓名', 
			'性別', 
			'生日', 
			'國碼', 
			'電話', 
			'國家', 
			'身份證明', 
			'單位', 
			'居住地', 
			'Email', 
			'建立時間', 
			'作者介紹', 
			'劇本名', 
			'投稿組別', 
			'劇本大綱', 
			'是否參與其他競賽', 
			'劇本發表', 
			'PDF', 
			'Word', 
			'上傳時間' 
		);
		foreach($headers as $value){
            $worksheet->setCellValueByColumnAndRow($columnN, $rowN, $value);
			$columnN++;
		}

		$members = $this->competition_m->get_items(false);
		$rowN++;
		foreach($members as $member){
			$data = array(
				$member->id, 
				$member->name, 
				($member->gender == 'f') ? '女' : '男', 
				$member->birthday, 
				$member->phone_country_code, 
				$member->phone, 
				$member->country, 
				$member->attachment, 
				$member->company, 
				$member->city, 
				$member->email, 
				$member->created_time, 
				$member->introduction, 
				$member->title, 
				$member->language, 
				$member->summary, 
				($member->exclusive == 1) ? '是' : '否', 
				($member->public == 1) ? '是' : '否', 
				$member->pdf, 
				$member->word, 
				$member->upload_time
			);

			$columnN = 0;
			foreach($data as $value){
	            $worksheet->setCellValueByColumnAndRow($columnN, $rowN, $value);
				$columnN++;
			}

			$rowN++;
		}

		$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
		$objWriter->save($file);

		$this->success_response($file_url);
	}

常用方法: