"PHPWord 서버에 저장하지 않고 다운로드시키기"의 두 판 사이의 차이

(새 문서: ;PHPWord 서버에 저장하지 않고 다운로드시키기 ==사전 작업== *PHPWord 설치 ==phpword1.php 작성== <source lang='cli'> [root@zetawiki ~]# cd /var/www/html [...)
 
14번째 줄: 14번째 줄:
</source>
</source>
<source lang='php'>
<source lang='php'>
<?php
require_once 'PHPWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addText( htmlspecialchars(
'"Hello" World. 안녕 친구들'
));
$section->addText( htmlspecialchars(
'"Lorem Ipsum 로렘 입숨'
),
array('name' => 'Tahoma', 'size' => 10)
);
$writer = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="phpword1.xlsx"');
header('Cache-Control: max-age=0');
$writer->save('php://output');
</source>
</source>



2015년 9월 3일 (목) 13:02 판

PHPWord 서버에 저장하지 않고 다운로드시키기

1 사전 작업

2 phpword1.php 작성

[root@zetawiki ~]# cd /var/www/html
[root@zetawiki html]# mkdir -p ex/phpword
[root@zetawiki html]# cd ex/phpword
[root@zetawiki phpword]# pwd
/var/www/html/ex/phpword
[root@zetawiki phpword]# vi phpword1.php
<?php
require_once 'PHPWord/Autoloader.php';
\PhpOffice\PhpWord\Autoloader::register();
 
$phpWord = new \PhpOffice\PhpWord\PhpWord();
 
$section = $phpWord->addSection();
$section->addText( htmlspecialchars(
		'"Hello" World. 안녕 친구들'
	));
$section->addText( htmlspecialchars(
		'"Lorem Ipsum 로렘 입숨'
	),
		array('name' => 'Tahoma', 'size' => 10)
	);
 
$writer = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');

header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="phpword1.xlsx"');
header('Cache-Control: max-age=0');

$writer->save('php://output');

3 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}