ユーザ入力に基づいていくつかの単語文書の内容を置き換える必要があります。 .docx(Word)ファイルの内容を読み込んで置換する
To,
The Office,
{officeaddress}
Sub: Authorization Letter
Sir/Madam,
I/We hereby authorize to {Ename} whose signature is attested here below, to submit application and collect Residential permit for {name}
Kindly allow him to support our International assignee
{name} {Ename}
が方法はあります:私は、テンプレートファイル(例えば "template.docx")を読んで、そして
template.docxまず{fname}という名前、住所、{アドレス}などを交換しようとしていますLaravel 5.3でも同じことをしていますか?
私はphpwordでしようとしていますが、私は新しい単語ファイルを書くためのコードしか見ることができませんが、既存のものを読んだり置き換えたりすることはできません。また、私が単純に読み書きすると、書式設定がうまくいきません。
コード:
$file = public_path('template.docx');
$phpWord = \PhpOffice\PhpWord\IOFactory::load($file);
$phpWord->save('b.docx');
b.docx
To,
The Office,
{officeaddress}
Sub:
Authorization Letter
Sir/Madam,
I/We hereby authorize
to
{Ename}
whose signature is attested here below, to submit a
pplication and collect Residential permit
for
{name}
Kindly allow him to support our International assignee
{name}
{
E
name}
このパッケージで実行できます:https://github.com/guiguidoc/laravel-phpword h ttps://github.com/PHPOffice/PHPWord –
は、.docxファイルからの読み込みの例です。https://github.com/PHPOffice/PHPWord/blob/develop/samples/Sample_11_ReadWord2007.php –
ありがとうございます - 私は彼らに試してみましょう。 –