亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法在表格中添加邊框樣式 (phpword)

無法在表格中添加邊框樣式 (phpword)

PHP
茅侃侃 2022-09-03 14:47:29
我正在嘗試在html內的表格中添加邊框。下面是我的代碼$phpWord = new \PhpOffice\PhpWord\PhpWord();$section = $phpWord->addSection();$html = "<table border='1'><tr><th>name</th></tr><tr><td>John</td></tr></table>";\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html );header('Content-Type: application/octet-stream');header('Content-Disposition: attachment;filename="test.docx"');$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');$objWriter->save('php://output');我已經分配了一個1的邊界,但它不起作用。我的表格中沒有邊框它事件不能通過添加樣式來工作。請幫忙
查看完整描述

2 回答

?
阿晨1998

TA貢獻2037條經驗 獲得超6個贊

在這種情況下,請使用內聯 CSS。你應該這樣做:


require_once __DIR__ . '/vendor/autoload.php';


use PhpOffice\PhpWord\IOFactory;

use PhpOffice\PhpWord\PhpWord;

use PhpOffice\PhpWord\Shared\Html;


$phpWord = new PhpWord();

$section = $phpWord->addSection();

$html = "<table style="border: 1px solid black;">

<tr>

<th>name</th>

</tr>

<tr><td>John</td></tr>

</table>";

Html::addHtml($section, $html);

header('Content-Type: application/octet-stream');

header('Content-Disposition: attachment;filename="test.docx"');

$objWriter = IOFactory::createWriter($phpWord);

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


查看完整回答
反對 回復 2022-09-03
?
蝴蝶不菲

TA貢獻1810條經驗 獲得超4個贊

嘗試以最少的更改運行代碼,并且全部工作)


require_once __DIR__ . '/vendor/autoload.php';


use PhpOffice\PhpWord\IOFactory;

use PhpOffice\PhpWord\PhpWord;

use PhpOffice\PhpWord\Shared\Html;


$phpWord = new PhpWord();

$section = $phpWord->addSection();

$html = "<table border='1'>

<tr>

<th>name</th>

</tr>

<tr><td>John</td></tr>

</table>";

Html::addHtml($section, $html);

header('Content-Type: application/octet-stream');

header('Content-Disposition: attachment;filename="test.docx"');

$objWriter = IOFactory::createWriter($phpWord);

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


查看完整回答
反對 回復 2022-09-03
  • 2 回答
  • 0 關注
  • 258 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號