使用phpword更新word文档,但格式正在改变

时间:2016-03-19 18:13:47

标签: phpword

我的文字doc采用以下格式

The Capital of this Partnership shall be the sum of Rs ______________/- (Rupees ____________________________________ Only) which shall be contributed by the Parties in following proportion: a. First Party: Rs ____________ /- b. Second Party: Rs _____________/- c. Third Party: Rs _______________/-

我已经按照以下格式编辑了我的Word文档,以便phpword setValue方法正常工作

The Capital of this Partnership shall be the sum of Rs $(value1)/- (Rupees $(value2) Only) which shall be contributed by the Parties in following proportion: a. First Party: Rs $(value3) /- b. Second Party: Rs $(value4)/- c. Third Party: Rs $(value5)/-

编写以下php代码来替换文档中的文字

<?php
require_once '../PHPWord.php';

$PHPWord = new PHPWord();

$document = $PHPWord->loadTemplate('Template.docx');
$document->setValue('Value1', '100');
$document->setValue('Value2', 'hundred');
$document->setValue('Value3', '50');
$document->setValue('Value4', '25');
$document->setValue('Value5', '25');
$document->save('CAPITAL.docx');
?>

正在保存word文档并正在进行更改,但文档的格式正在改变,如

The Capital of this Partnership shall be the sum of Rs 100/- (Rupees hundred Only) which shall be contributed by the Parties in following proportion: a. First Party: Rs 50/- b. Second Party: Rs 25/- c. Third Party: Rs 25/-

我希望所有单词保留在原位,输入的长度也应相同(例如____________/-应为50 /-

0 个答案:

没有答案