setValuesFromArray($data); echo '
'; echo date('H:i:s'), ' 导出完成', EOL; $templateProcessor->saveAs($wsmb_path1); // 下载Word文件 if(ob_get_length()) ob_end_clean();//这一句必须,没有这一句,linux生成的word会提示文件损坏 header('Cache-control: max-age=360'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Length: '.filesize($wsmb_path1)); header('Content-Transfer-Encoding: binary'); header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Expires: '.gmdate("D, d M Y H:i:s", time() + 360) . ' GMT'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Pragma: public'); ob_start(); //打开缓冲区 echo file_get_contents($wsmb_path1); @unlink($wsmb_path1); ob_end_flush();//输出全部内容到浏览器 exit(); } function export_fhrzjd($data) { require_once('./ThinkPHP/Library/Vendor/autoload.php'); define("PUBLIC_PATH", $_SERVER["DOCUMENT_ROOT"] . "/Public/file"); $filename="RF-228-Ⅳ-2020 复核和认证决定评定表.docx"; $wsmb_path = PUBLIC_PATH . "/RF-228-Ⅳ-2020 复核和认证决定评定表.docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-228-Ⅳ-2020 复核和认证决定评定表1.docx"; echo date('H:i:s'), '开始导出...', EOL; $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($wsmb_path); $templateProcessor->setValuesFromArray($data); echo '
'; echo date('H:i:s'), ' 导出完成', EOL; $templateProcessor->saveAs($wsmb_path1); // 下载Word文件 if(ob_get_length()) ob_end_clean();//这一句必须,没有这一句,linux生成的word会提示文件损坏 header('Cache-control: max-age=360'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Length: '.filesize($wsmb_path1)); header('Content-Transfer-Encoding: binary'); header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Expires: '.gmdate("D, d M Y H:i:s", time() + 360) . ' GMT'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Pragma: public'); ob_start(); //打开缓冲区 echo file_get_contents($wsmb_path1); @unlink($wsmb_path1); ob_end_flush();//输出全部内容到浏览器 exit(); } function export_zgpdyj($data) { require_once('./ThinkPHP/Library/Vendor/autoload.php'); define("PUBLIC_PATH", $_SERVER["DOCUMENT_ROOT"] . "/Public/file"); $filename="RF-230-Ⅳ-2020 复核与认证决定不符合整改评定意见表.docx"; $wsmb_path = PUBLIC_PATH . "/RF-230-Ⅳ-2020 复核与认证决定不符合整改评定意见表.docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-230-Ⅳ-2020 复核与认证决定不符合整改评定意见表1.docx"; echo date('H:i:s'), '开始导出...', EOL; $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($wsmb_path); $templateProcessor->setValuesFromArray($data); echo '
'; echo date('H:i:s'), ' 导出完成', EOL; $templateProcessor->saveAs($wsmb_path1); // 下载Word文件 if(ob_get_length()) ob_end_clean();//这一句必须,没有这一句,linux生成的word会提示文件损坏 header('Cache-control: max-age=360'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Length: '.filesize($wsmb_path1)); header('Content-Transfer-Encoding: binary'); header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Expires: '.gmdate("D, d M Y H:i:s", time() + 360) . ' GMT'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Pragma: public'); ob_start(); //打开缓冲区 echo file_get_contents($wsmb_path1); @unlink($wsmb_path1); ob_end_flush();//输出全部内容到浏览器 exit(); } function export_xcjc($param, $check) { require_once('./ThinkPHP/Library/Vendor/autoload.php'); define("PUBLIC_PATH", $_SERVER["DOCUMENT_ROOT"] . "/public//file"); //设置加载模板路径 if($param == 1) { $filename="RF-219-Ⅳ-2020 现场检查表(农场基础).docx"; $wsmb_path = PUBLIC_PATH . "/RF-219-Ⅳ-2020 现场检查表(农场基础).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-219-Ⅳ-2020 现场检查表(农场基础)1.docx"; }else if($param == 2) { $filename="RF-220-Ⅳ-2020 现场检查表(作物基础).docx"; $wsmb_path = PUBLIC_PATH . "/RF-220-Ⅳ-2020 现场检查表(作物基础).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-220-Ⅳ-2020 现场检查表(作物基础)1.docx"; }else if($param == 3) { $filename="RF-221-Ⅳ-2020 现场检查表(大田作物).docx"; $wsmb_path = PUBLIC_PATH . "/RF-221-Ⅳ-2020 现场检查表(大田作物).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-221-Ⅳ-2020 现场检查表(大田作物)1.docx"; }else if($param == 4) { $filename="RF-222-Ⅳ-2020 现场检查表(果蔬模块).docx"; $wsmb_path = PUBLIC_PATH . "/RF-222-Ⅳ-2020 现场检查表(果蔬模块).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-222-Ⅳ-2020 现场检查表(果蔬模块)1.docx"; }else if($param == 5) { $filename="RF-223-Ⅳ-2020 现场检查表(茶叶模块).docx"; $wsmb_path = PUBLIC_PATH . "/RF-223-Ⅳ-2020 现场检查表(茶叶模块).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-223-Ⅳ-2020 现场检查表(茶叶模块)1.docx"; } else if($param == 'a') { $filename="RF-236-Ⅳ-2020 现场检查表(畜禽基础).docx"; $wsmb_path = PUBLIC_PATH . "/RF-236-Ⅳ-2020 现场检查表(畜禽基础).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-236-Ⅳ-2020 现场检查表(畜禽基础)1.docx"; } else if($param == 'b') { $filename="RF-237-Ⅳ-2020 现场检查表(牛羊模块).docx"; $wsmb_path = PUBLIC_PATH . "/RF-237-Ⅳ-2020 现场检查表(牛羊模块).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-237-Ⅳ-2020 现场检查表(牛羊模块)1.docx"; } else if($param == 'c') { $filename="RF-238-Ⅳ-2020 现场检查表(奶牛模块).docx"; $wsmb_path = PUBLIC_PATH . "/RF-238-Ⅳ-2020 现场检查表(奶牛模块).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-238-Ⅳ-2020 现场检查表(奶牛模块)1.docx"; } else if($param == 'd') { $filename="RF-239-Ⅳ-2020 现场检查表(生猪模块).docx"; $wsmb_path = PUBLIC_PATH . "/RF-239-Ⅳ-2020 现场检查表(生猪模块).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-239-Ⅳ-2020 现场检查表(生猪模块)1.docx"; } else if($param == 'e') { $filename="RF-240-Ⅳ-2020 现场检查表(家禽模块).docx"; $wsmb_path = PUBLIC_PATH . "/RF-240-Ⅳ-2020 现场检查表(家禽模块).docx"; $wsmb_path1 = PUBLIC_PATH ."/RF-240-Ⅳ-2020 现场检查表(家禽模块)1.docx"; } echo date('H:i:s'), '开始导出...', EOL; $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($wsmb_path); $templateProcessor->setValuesFromArray($check); /* // Variables on different parts of document $templateProcessor->setValue('weekday', date('l')); // On section/content $templateProcessor->setValue('time', date('H:i')); // On footer $templateProcessor->setValue('serverName', realpath(__DIR__)); // On header // Simple table $templateProcessor->cloneRow('rowValue', 10); $templateProcessor->setValue('rowValue#1', 'Sun'); $templateProcessor->setValue('rowValue#2', 'Mercury'); $templateProcessor->setValue('rowValue#3', 'Venus'); $templateProcessor->setValue('rowValue#4', 'Earth'); $templateProcessor->setValue('rowValue#5', 'Mars'); $templateProcessor->setValue('rowValue#6', 'Jupiter'); $templateProcessor->setValue('rowValue#7', 'Saturn'); $templateProcessor->setValue('rowValue#8', 'Uranus'); $templateProcessor->setValue('rowValue#9', 'Neptun'); $templateProcessor->setValue('rowValue#10', 'Pluto'); $templateProcessor->setValue('rowNumber#1', '1'); $templateProcessor->setValue('rowNumber#2', '2'); $templateProcessor->setValue('rowNumber#3', '3'); $templateProcessor->setValue('rowNumber#4', '4'); $templateProcessor->setValue('rowNumber#5', '5'); $templateProcessor->setValue('rowNumber#6', '6'); $templateProcessor->setValue('rowNumber#7', '7'); $templateProcessor->setValue('rowNumber#8', '8'); $templateProcessor->setValue('rowNumber#9', '9'); $templateProcessor->setValue('rowNumber#10', '10'); // Table with a spanned cell $values = array( array( 'userId' => 1, 'userFirstName' => 'James', 'userName' => 'Taylor', 'userPhone' => '+1 428 889 773', ), array( 'userId' => 2, 'userFirstName' => 'Robert', 'userName' => 'Bell', 'userPhone' => '+1 428 889 774', ), array( 'userId' => 3, 'userFirstName' => 'Michael', 'userName' => 'Ray', 'userPhone' => '+1 428 889 775', ), ); $templateProcessor->cloneRowAndSetValues('userId', $values); //this is equivalent to cloning and settings values with cloneRowAndSetValues // $templateProcessor->cloneRow('userId', 3); // $templateProcessor->setValue('userId#1', '1'); // $templateProcessor->setValue('userFirstName#1', 'James'); // $templateProcessor->setValue('userName#1', 'Taylor'); // $templateProcessor->setValue('userPhone#1', '+1 428 889 773'); // $templateProcessor->setValue('userId#2', '2'); // $templateProcessor->setValue('userFirstName#2', 'Robert'); // $templateProcessor->setValue('userName#2', 'Bell'); // $templateProcessor->setValue('userPhone#2', '+1 428 889 774'); // $templateProcessor->setValue('userId#3', '3'); // $templateProcessor->setValue('userFirstName#3', 'Michael'); // $templateProcessor->setValue('userName#3', 'Ray'); // $templateProcessor->setValue('userPhone#3', '+1 428 889 775'); */ echo '
'; echo date('H:i:s'), ' 导出完成', EOL; $templateProcessor->saveAs($wsmb_path1); // 下载Word文件 if(ob_get_length()) ob_end_clean();//这一句必须,没有这一句,linux生成的word会提示文件损坏 header('Cache-control: max-age=360'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Length: '.filesize($wsmb_path1)); header('Content-Transfer-Encoding: binary'); header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Expires: '.gmdate("D, d M Y H:i:s", time() + 360) . ' GMT'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Pragma: public'); ob_start(); //打开缓冲区 echo file_get_contents($wsmb_path1); @unlink($wsmb_path1); ob_end_flush();//输出全部内容到浏览器 exit(); } function export_xcjc1($info) { require_once('./ThinkPHP/Library/Vendor/autoload.php'); $PHPWord = new PHPWord(); // 新节 $section = $PHPWord->createSection();//新建页面 // $fileName = "现场检查-".$info['cp_name'].'-'.date("YmdHis"); $fileName = "现场检查-".date("YmdHis"); header("Content-type: application/vnd.ms-word"); header("Content-Disposition:attachment;filename=".$fileName.".docx"); header('Cache-Control: max-age=0'); $objWriter = IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('php://output'); } //新版 function export_zhinan($info) { // require_once('./ThinkPHP/Library/Vendor/Word/PHPWord.php'); // require_once('./ThinkPHP/Library/Vendor/Word/PHPWord/IOFactory.php'); require_once('./ThinkPHP/Library/Vendor/autoload.php'); // $PHPWord = new \PHPWord(); $PHPWord = new PHPWord(); // $SPACE = ' '; //七个空格 $SPACE = ''; //七个空格,用样式缩进替代 // 新节 $section = $PHPWord->createSection();//新建页面 // 页脚 // $footer = $section->createFooter(); // $footer->addPreserveText(' —{PAGE}— ', array('align'=>'center',size=>"10")); //添加表格样式 // $styleTable=array('borderColor'=>'000000','borderSize'=>6); // $PHPWord->addTableStyle('myOwnTableStyle', $styleTable); $cp_name = $info['cp_name']; $zhengshu_num = $info['zhengshu_num']; // $title_1 = '一、主要产地'; // $title_2 = '二、品质特征'; // $title_4 = '三、环境优势'; // $title_5 = '四、收获时间'; // $title_7 = '五、推荐贮藏保鲜方法'; // $title_8 = '六、产品和环境图片'; // $title_9 = '七、推荐食用方法'; // $title_10 = '八、市场销售采购信息'; // $title_11 = '九、供稿人'; // $content_1 = $info['place']; // $content_2 = $info['ganguan']; // $content_3 = $info['pinzhi']; // $content_4 = $info['huanjing']; // $content_5 = $info['crop_time']; // $content_6 = $info['best_time']; // $content_7 = $info['save_method']; $title_1 = '一、主要产地'; $title_2 = '二、品质特征'; $title_3 = '三、环境优势'; $title_4 = '四、收获时间'; $title_5 = '五、储藏保鲜方法和食用方法'; $title_6 = '六、市场销售采购信息'; $title_7 = '七、供稿人'; $content_1 = $info['place']; $content_2_1 = $info['ganguan']; $content_2_2 = $info['pinzhi']; $content_3 = $info['huanjing']; $content_4_1 = $info['crop_time']; $content_4_2 = $info['best_time']; $content_5 = $info['save_method']; //供稿人 $dw_name = $info['ggdw'] ? $info['ggdw'] : $info['dw_name']; $content_7 = $dw_name . ' ' . $info['ggr']; $PHPWord->addParagraphStyle( 'Normal',array( 'align'=>'left', 'spaceBefore' => 0, 'spaceAfter' => 0, 'spacing'=>100, 'lineHeight' => 1.19, // 行间距 'indentation' => array( // 首行缩进 'firstLine' => 460 ) ) ); //addText(文本,文本样式-数组,段落样式-数组) //添加文本 $section->addText($cp_name, ['size'=>'24','bold'=>true], ['align'=>'center']);//产品名称 $section->addTextBreak(1); $section->addText($zhengshu_num, ['size'=>'16'], ['align'=>'center']);//证书编号 //样式 $font_style_title = ['size'=>18,'bold'=>true]; $text_style_title = ['align'=>'left']; $font_style = ['size'=>16]; // $text_style = ['align'=>'left','indentFirstLine'=>620]; $text_style ='Normal'; $section->addTextBreak(1);//主要产地 $section->addText($title_1, $font_style_title, $text_style_title); // $section->addText($SPACE . $content_1, $font_style, $text_style); $textlines = explode(PHP_EOL, $content_1); foreach($textlines as $line) { // $section->addTextBreak(); $section->addText($line, $font_style, 'Normal'); } $section->addTextBreak(1);//品质特征 $section->addText($title_2, $font_style_title, $text_style_title); // $section->addText($SPACE . $content_2_1, $font_style, $text_style); $textlines = explode(PHP_EOL, $content_2_1); foreach($textlines as $line) { // $section->addTextBreak(); $section->addText($line, $font_style, 'Normal'); } // $section->addText($SPACE . $content_2_2, $font_style, $text_style); $textlines = explode(PHP_EOL, $content_2_2); foreach($textlines as $line) { // $section->addTextBreak(); $section->addText($line, $font_style, 'Normal'); } $section->addTextBreak(1);//环境优势 $section->addText($title_3, $font_style_title, $text_style_title); // $section->addText($SPACE . $content_3, $font_style, $text_style); $textlines = explode(PHP_EOL, $content_3); foreach($textlines as $line) { // $section->addTextBreak(); $section->addText($line, $font_style, 'Normal'); } $section->addTextBreak(1);//收获时间 $section->addText($title_4, $font_style_title, $text_style_title); $content_4 = $content_4_1; if( strpos($content_4_1, '最佳品质期') === false ) { $content_4 .= ' 最佳品质期为'.$content_4_2; } // $section->addText($SPACE . $content_4, $font_style, $text_style); $textlines = explode(PHP_EOL, $content_4); foreach($textlines as $line) { // $section->addTextBreak(); $section->addText($line, $font_style, 'Normal'); } $section->addTextBreak(1);//推荐贮藏保鲜方法 $section->addText($title_5, $font_style_title, $text_style_title); // $section->addText($SPACE . '储藏办法:'.$content_5, $font_style, $text_style); $textlines = explode(PHP_EOL,'储藏办法:'.$content_5); foreach($textlines as $line) { // $section->addTextBreak(); $section->addText($line, $font_style, 'Normal'); } $section->addTextBreak(1);//食用方法 $image_style = ['width'=>400]; foreach ($info['uses'] as $use) { if($use['use_txt']) { // $chars = iconv("utf-8","gb2312//IGNORE",$use['use_txt']); $chars = $use['use_txt']; // $section->addText($SPACE . $chars, $font_style, $text_style); $textlines = explode(PHP_EOL,$chars); foreach($textlines as $line) { // $section->addTextBreak(); $section->addText($line, $font_style, 'Normal'); } } foreach ($use['use_pic_arr'] as $img1) { $section->addImage($img1, $image_style); } $section->addTextBreak(1); } $section->addTextBreak(1);//市场销售采购信息 $section->addText($title_6, $font_style_title, $text_style_title); foreach ($info['sales'] as $sale) { if($sale['sale_txt']) { // $section->addText($SPACE . $sale['sale_txt'], $font_style, $text_style); $textlines = explode(PHP_EOL,$sale['sale_txt']); foreach($textlines as $line) { // $section->addTextBreak(); $section->addText($line, $font_style, 'Normal'); } } foreach ($sale['sale_qr_arr'] as $img2) { // $section->addImage($img2, $image_style); if(getimagesize($img2)[0]>400){ $section->addImage($img2, $image_style); }else{ $section->addImage($img2); } } // $section->addTextBreak(1); } $dw_name = $info['ggdw'] ? $info['ggdw'] : $info['dw_name']; $section->addTextBreak(1);//供稿人 $section->addText($title_7, $font_style_title, $text_style_title); $section->addText($SPACE . $content_7, $font_style, $text_style); //图片样式 // $image_style = ['width'=>'600','height'=>'400']; $section->addTextBreak(1);//八、产品和环境图片 foreach ($info['other_img_arr'] as $image) { // $section->addImage($image, $image_style); if(getimagesize($image)[0]>400){ $section->addImage($image, $image_style); }else{ $section->addImage($image); } } // $section->addPageBreak(); //添加分页符 $fileName = "消费指南-".$info['cp_name'].'-'.date("YmdHis"); header("Content-type: application/vnd.ms-word"); header("Content-Disposition:attachment;filename=".$fileName.".docx"); header('Cache-Control: max-age=0'); // $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter = IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('php://output'); } //备份,被上面函数替换 function export_zhinan1($info) { require_once('./ThinkPHP/Library/Vendor/Word/PHPWord.php'); require_once('./ThinkPHP/Library/Vendor/Word/PHPWord/IOFactory.php'); $PHPWord = new \PHPWord(); $SPACE = ' '; //七个空格 // 新节 $section = $PHPWord->createSection();//新建页面 // 页脚 // $footer = $section->createFooter(); // $footer->addPreserveText(' —{PAGE}— ', array('align'=>'center',size=>"10")); //添加表格样式 // $styleTable=array('borderColor'=>'000000','borderSize'=>6); // $PHPWord->addTableStyle('myOwnTableStyle', $styleTable); $cp_name = $info['cp_name']; $zhengshu_num = $info['zhengshu_num']; // $title_1 = '一、主要产地'; // $title_2 = '二、品质特征'; // $title_4 = '三、环境优势'; // $title_5 = '四、收获时间'; // $title_7 = '五、推荐贮藏保鲜方法'; // $title_8 = '六、产品和环境图片'; // $title_9 = '七、推荐食用方法'; // $title_10 = '八、市场销售采购信息'; // $title_11 = '九、供稿人'; // $content_1 = $info['place']; // $content_2 = $info['ganguan']; // $content_3 = $info['pinzhi']; // $content_4 = $info['huanjing']; // $content_5 = $info['crop_time']; // $content_6 = $info['best_time']; // $content_7 = $info['save_method']; $title_1 = '一、主要产地'; $title_2 = '二、品质特征'; $title_3 = '三、环境优势'; $title_4 = '四、收获时间'; $title_5 = '五、储藏保鲜方法和食用方法'; $title_6 = '六、市场销售采购信息'; $title_7 = '七、供稿人'; $content_1 = $info['place']; $content_2_1 = $info['ganguan']; $content_2_2 = $info['pinzhi']; $content_3 = $info['huanjing']; $content_4_1 = $info['crop_time']; $content_4_2 = $info['best_time']; $content_5 = $info['save_method']; //供稿人 $dw_name = $info['ggdw'] ? $info['ggdw'] : $info['dw_name']; $content_7 = $dw_name . ' ' . $info['ggr']; //addText(文本,文本样式-数组,段落样式-数组) //添加文本 $section->addText($cp_name, ['size'=>'24','bold'=>true], ['align'=>'center']);//产品名称 $section->addTextBreak(1); $section->addText($zhengshu_num, ['size'=>'16'], ['align'=>'center']);//证书编号 //样式 $font_style_title = ['size'=>18,'bold'=>true]; $text_style_title = ['align'=>'left']; $font_style = ['size'=>16]; $text_style = ['align'=>'left','indentFirstLine'=>620]; // $text_style = ['align'=>'left','indentFirstLineChars'=>620,'indentLeft' => 1440]; // $text_style = array('indentLeft' => 1440); $section->addTextBreak(1);//主要产地 $section->addText($title_1, $font_style_title, $text_style_title); $section->addText($SPACE . $content_1, $font_style, $text_style); $section->addTextBreak(1);//品质特征 $section->addText($title_2, $font_style_title, $text_style_title); $section->addText($SPACE . $content_2_1, $font_style, $text_style); $section->addText($SPACE . $content_2_2, $font_style, $text_style); $section->addTextBreak(1);//环境优势 $section->addText($title_3, $font_style_title, $text_style_title); $section->addText($SPACE . $content_3, $font_style, $text_style); $section->addTextBreak(1);//收获时间 $section->addText($title_4, $font_style_title, $text_style_title); $content_4 = $content_4_1; if( strpos($content_4_1, '最佳品质期') === false ) { $content_4 .= ' 最佳品质期为'.$content_4_2; } $section->addText($SPACE . $content_4, $font_style, $text_style); $section->addTextBreak(1);//推荐贮藏保鲜方法 $section->addText($title_5, $font_style_title, $text_style_title); $section->addText($SPACE . '储藏办法:'.$content_5, $font_style, $text_style); $section->addTextBreak(1);//食用方法 foreach ($info['uses'] as $use) { if($use['use_txt']) { // $chars = iconv("utf-8","gb2312//IGNORE",$use['use_txt']); $chars = $use['use_txt']; $section->addText($SPACE . $chars, $font_style, $text_style); } foreach ($use['use_pic_arr'] as $img1) { $section->addImage($img1, $image_style); } $section->addTextBreak(1); } $section->addTextBreak(1);//市场销售采购信息 $section->addText($title_6, $font_style_title, $text_style_title); foreach ($info['sales'] as $sale) { if($sale['sale_txt']) { $section->addText($SPACE . $sale['sale_txt'], $font_style, $text_style); } foreach ($sale['sale_qr_arr'] as $img2) { $section->addImage($img2, $image_style); } // $section->addTextBreak(1); } $dw_name = $info['ggdw'] ? $info['ggdw'] : $info['dw_name']; $section->addTextBreak(1);//供稿人 $section->addText($title_7, $font_style_title, $text_style_title); $section->addText($SPACE . $content_7, $font_style, $text_style); //图片样式 $image_style = ['width'=>'600','height'=>'400']; $section->addTextBreak(1);//八、产品和环境图片 foreach ($info['other_img_arr'] as $image) { $section->addImage($image, $image_style); } // $section->addPageBreak(); //添加分页符 $fileName = "消费指南-".$info['cp_name'].'-'.date("YmdHis"); header("Content-type: application/vnd.ms-word"); header("Content-Disposition:attachment;filename=".$fileName.".docx"); header('Cache-Control: max-age=0'); $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('php://output'); }