优化标签单导出功能

- 移除了每个条目后的强制分页,只在非最后一个条目时添加分页
- 修正了文件名中的日期格式,使其与实际导出时间一致
- 代码格式调整,提高可读性和维护性
This commit is contained in:
mkm 2024-10-09 15:32:47 +08:00
parent 69b4a8cafe
commit 7f43276720

View File

@ -26,15 +26,17 @@ class Beforehand
$fontStyle2 = ['name' => 'Arial', 'size' => 8, 'bold' => true];
$fontStyle3 = ['name' => 'Arial', 'size' => 8, 'bold' => true];
$count = count($data);
foreach ($data as $k => $v) {
$textRun = $section->addTextRun();
$textRun->addText($v['system_store'], $fontStyle);
$textRun->addText(' ' . $v['subtitle'], $fontStyle1);
$section->addText(mb_substr( $v['store_name'], 0, 16, 'UTF-8'), $fontStyle2);
$section->addText($v['store_name'], $fontStyle2);
$section->addText($v['address'], $fontStyle3);
if($k+1!=$count){
$section->addPageBreak();
}
}
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');