代码拉取完成,页面将自动刷新
同步操作将从 李春林/phpoffice-phpword-phpexcel 独立版 PHP56 兼容WIN LINUX 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
phpword
但又没有安装compower
或者不喜欢composer
的童鞋为什么不是 PhpSpreadsheet 为了向下兼容^_^
src/Common
src/PhpWord
Classes
phpoffice(任意目录)
│ ├─common (公共类)
│ ├─phpexcel
│ ├─phpword
│ ├─phpexcel.php
│ └─phpword.php
└─readme.md
<?php
spl_autoload_register(function ($class) {
$class = ltrim($class, '\\');
$prefix = 'PhpOffice\PhpWord';
if (strpos($class, $prefix) === 0) {
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$class = implode(DIRECTORY_SEPARATOR, array('phpword','PhpWord')) . substr($class, strlen($prefix));
$file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php';
var_dump($file);
if (file_exists($file)) {
require_once $file;
}
}
});
require_once __DIR__ . "/common/Autoloader.php";
\PhpOffice\Common\Autoloader::register();
include('phpoffice/phpword.php');
$PHPWord = new \PhpOffice\PhpWord\PhpWord();
# code...干你该干的事
include('phpoffice/phpword.php');
$PHPWord = new \PhpOffice\PhpWord\PhpWord();
//加载
$tempPlete = $PHPWord->loadTemplate($doc_file);
//替换 word里的字符为 ${abc}
//照片
$tempPlete->setImageValue('photo_url', ['path' => $v,'width'=>120,'height'=>170]);
//普通
$tempPlete->setValue('field','abc');
//输出
$filename = "[{$data['cat_text']}]-{$data['name']}.docx";
header('Content-Type: application/vnd.ms-word');
header('Content-Disposition: attachment;filename='.$filename);
header('Cache-Control: max-age=0');
$tempPlete->saveAs('php://output');//直接下载
//保存
//$tempPlete->saveAs($save_path.(iconv('utf-8','GB2312//IGNORE',$filename)));
require_once('phpoffice/phpexcel.php');
$objPHPExcel = new \PHPExcel();
# code...干你该干的事
$filename = "xxx.xls";
$objWrite = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWrite->save($save_path.(iconv('utf-8','GB2312//IGNORE',$filename)));
return false;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。