PHP 내 보 내기 스타일 의 Excel 예제 코드
작업 중 내 보 낼 때 사용자 정의 표를 내 보 내 거나 내 보 내기 싫어 하 는 Excel 형식 이 너무 보기 싫 습 니 다.이 럴 때 는 색상,글꼴 크기,굵기,셀 병합 등 을 설정 해 야 합 니 다.이 글 은 실례 를 통 해 여러분 에 게 어떻게 하 는 지 알려 드 리 겠 습 니 다.다음은 함께 보 겠 습 니 다.
먼저 효과 도 를 살 펴 보 자.
인 스 턴 스 코드
PHP 코드:
/**
*
* @return string
*/
public function export()
{
$file_name = " -".date("Y-m-d H:i:s",time());
$file_suffix = "xls";
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file_name.$file_suffix");
// , 。
$this->display();
}
HTML 코드:
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 11">
</head>
<body>
<table border=1 cellpadding=0 cellspacing=0 width="100%" >
<tr>
<td colspan="5" align="center">
<h2> </h2>
</td>
</tr>
<tr>
<td style='width:54pt' align="center"> </td>
<td style='width:54pt' align="center"> </td>
<td style='width:54pt' align="center"> </td>
<td style='width:54pt' align="center"> </td>
<td style='width:54pt' align="center"> </td>
</tr>
<tr>
<td align="center">1</td>
<td style="background-color: #00CC00;" align="center">Jone</td>
<td style="background-color: #00adee;" align="center">90</td>
<td style="background-color: #00CC00;" align="center">85</td>
<td style="background-color: #00adee;" align="center">100</td>
</tr>
<tr>
<td align="center">2</td>
<td style="background-color: #00CC00;" align="center">Tom</td>
<td style="background-color: #00adee;" align="center">99</td>
<td style="background-color: #00CC00;" align="center">85</td>
<td style="background-color: #00adee;" align="center">80</td>
</tr>
</table>
</body>
</html>
이상 은 본 고의 모든 내용 입 니 다.본 고 는 사례 를 통 해 매우 상세 하 게 소개 되 었 습 니 다.여러분 의 학습 과 업무 에 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 면 메 시 지 를 남 겨 주 십시오.저희 에 대한 지지 에 감 사 드 립 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Laravel - 변환된 유효성 검사 규칙으로 API 요청 제공동적 콘텐츠를 위해 API를 통해 Laravel CMS에 연결하는 모바일 앱(또는 웹사이트) 구축을 고려하십시오. 이제 앱은 CMS에서 번역된 콘텐츠를 받을 것으로 예상되는 다국어 앱이 될 수 있습니다. 일반적으로 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.