Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Fonts PHPWord-表格样式默认值始终为Arial 10,未应用新样式_Fonts_Styles_Phpword - Fatal编程技术网

Fonts PHPWord-表格样式默认值始终为Arial 10,未应用新样式

Fonts PHPWord-表格样式默认值始终为Arial 10,未应用新样式,fonts,styles,phpword,Fonts,Styles,Phpword,我在这里尝试了另一篇文章,重新命名没有被应用的样式,但是代码也没有起作用。在这里,我的PHPWord成功地构建了显示使用“开放SAN”的硬编码变量的部分;但当我改为在表格中显示信息时,它总是默认为“Arial”10。请看你是否能帮助告诉我为什么会发生这种情况,谢谢!注意-为了让输出在单元格之间均匀地显示线条,我正在尝试文本中的其他样式。即使我将$BodyFontStyle应用于每个addCell、addText和addRow,仍然只有-Arial。我需要表格以“开放式SAN”10显示。请救命-

我在这里尝试了另一篇文章,重新命名没有被应用的样式,但是代码也没有起作用。在这里,我的PHPWord成功地构建了显示使用“开放SAN”的硬编码变量的部分;但当我改为在表格中显示信息时,它总是默认为“Arial”10。请看你是否能帮助告诉我为什么会发生这种情况,谢谢!注意-为了让输出在单元格之间均匀地显示线条,我正在尝试文本中的其他样式。即使我将$BodyFontStyle应用于每个addCell、addText和addRow,仍然只有-Arial。我需要表格以“开放式SAN”10显示。请救命-

$firstRowStyle = array('name' => 'Open Sans', 'size' => 10, 'valign' => 'bottom');
$BodyFontStyle = array('name'=>'Open Sans', 'bold'=>false, 'size'=>14);
$table_cell_style = array('valign' => 'top');
$lineStyle = array('name' => 'Open Sans', 'size' => 10, 'valign' => 'bottom');

//from above, this flag is not set, or set:
if ($signatory_found == 1) { //from mySQL query looking for Signatory.

    $PHPWord->addTableStyle('BodyFontStyle', array('name'=>'Open Sans', 'bold'=>false, 'size'=>14));
    $table = $section->addTable('BodyFontStyle');

    //tried this, to no avail:
    //$PHPWord->addTableStyle($BodyFontStyle);
    //$table = $section->addTable($BodyFontStyle);

    for ($i=0; $i <= $counter; $i++) {
        $table->addRow();
        $table->addCell(1600, $firstRowStyle)->addText("BY:_____________________________________________________");
        $table->addCell(200, $firstRowStyle)->addText('');
        $table->addCell(1600, $firstRowStyle)->addText("     ____________________________");
        $table->addRow();

        $full_name_title = "    " . $signatory_results[$i]['first'] . " " . $signatory_results[$i]['last'] . ", " . $signatory_results[$i]['title'];

        $table->addCell(1600, $table_cell_style)->addText("{$full_name_title}");
        $table->addCell(200, $firstRowStyle)->addText(''); //space between name, and date.
        $table->addCell(1600, $table_cell_style)->addText("                          Date");
    }
} else { //else signatory flag was not set to 1, so no records found.

    $table = $section->addTable('BodyFontStyle');
    $PHPWord->addTableStyle('BodyFontStyle', array('name'=>'Open Sans', 'bold'=>false, 'size'=>14));

    $table->addRow();
    $table->addCell(1600, $firstRowStyle)->addText("BY:_________________________________");
    $table->addCell(200, $firstRowStyle)->addText('');
    $table->addCell(1600, $firstRowStyle)->addText("_______________________");

    $table->addRow();
    $table->addCell(1600, $firstRowStyle)->addText("          Signature");
    $table->addCell(200, $firstRowStyle)->addText('');
    $table->addCell(1600, $firstRowStyle)->addText("                Date");

    $table->addRow();
    $table->addCell(1600, $lineStyle)->addText("     ____________________________________", array(), array('cellMarginLeft' => 6));
    $table->addCell(200, $firstRowStyle)->addText('');
    $table->addCell(1600, $firstRowStyle)->addText("_______________________");

    $table->addRow();
    $table->addCell(1600, $table_cell_style)->addText("          Print Name");
    $table->addCell(200, $firstRowStyle)->addText('');
    $table->addCell(1600, $table_cell_style)->addText("                Print Title");
}

// Hack - Martin/Pitt has a / in the LP Short name which messes up the filename/path
$LPShort = str_replace("/", "-", $LPShort);
$LPShort = str_replace(" ", "-", $LPShort);

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter( $PHPWord, 'Word2007' );
$filelocation = '/var/www/company/contracts/tmp';
$filename = 'Sig_'.$LPShort."_".date('YmdHis',time()).'.docx';
$FullName = $filelocation.'/'.$filename;
//echo $FullName;
$objWriter->save($FullName);

echo $filename;
exit;
$firstRowStyle=array('name'=>'opensans','size'=>10','valign'=>'bottom');
$BodyFontStyle=array('name'=>'Open Sans','bold'=>false,'size'=>14);
$table_cell_style=array('valign'=>'top');
$lineStyle=array('name'=>'opensans','size'=>10,'valign'=>'bottom');
//从上面看,此标志未设置,或设置为:
如果($significator\u found==1){//从mySQL查询中查找签名者。
$PHPWord->addTableStyle('BodyFontStyle',数组('name'=>'Open Sans','bold'=>false','size'=>14));
$table=$section->addTable('BodyFontStyle');
//尝试了这个,但没有成功:
//$PHPWord->addTableStyle($BodyFontStyle);
//$table=$section->addTable($BodyFontStyle);
对于($i=0;$i addRow();
$table->addCell(1600,$firstRowStyle)->addText(“作者:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\;
$table->addCell(200,$firstRowStyle)->addText(“”);
$table->addCell(1600,$firstRowStyle)->addText(“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”);
$table->addRow();
$full_name_title=“”.$signature_results[$i]['first']。“$signature_results[$i]['last']。”,“$signature_results[$i]['title'];
$table->addCell(1600,$table_cell_style)->addText(“{$full_name_title}”);
$table->addCell(200,$firstRowStyle)->addText(“”);//名称和日期之间的空格。
$table->addCell(1600,$table\u cell\u样式)->addText(“日期”);
}
}else{//else签名标志未设置为1,因此未找到任何记录。
$table=$section->addTable('BodyFontStyle');
$PHPWord->addTableStyle('BodyFontStyle',数组('name'=>'Open Sans','bold'=>false','size'=>14));
$table->addRow();
$table->addCell(1600,$firstRowStyle)->addText(“由:uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”);
$table->addCell(200,$firstRowStyle)->addText(“”);
$table->addCell(1600,$firstRowStyle)->addText(“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”);
$table->addRow();
$table->addCell(1600,$firstRowStyle)->addText(“签名”);
$table->addCell(200,$firstRowStyle)->addText(“”);
$table->addCell(1600,$firstRowStyle)->addText(“日期”);
$table->addRow();
$table->addCell(1600,$lineStyle)->addText(“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;
$table->addCell(200,$firstRowStyle)->addText(“”);
$table->addCell(1600,$firstRowStyle)->addText(“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”);
$table->addRow();
$table->addCell(1600,$table\u cell\u样式)->addText(“打印名称”);
$table->addCell(200,$firstRowStyle)->addText(“”);
$table->addCell(1600,$table\u cell\u样式)->addText(“打印标题”);
}
//Hack-Martin/Pitt在LP短名称中有一个/,这会弄乱文件名/路径
$LPShort=str_替换(“/”、“-”、$LPShort);
$LPShort=str_替换(“,”-“,$LPShort);
$objWriter=\PhpOffice\PhpWord\IOFactory::createWriter($PhpWord,'Word2007');
$filelocation='/var/www/company/contracts/tmp';
$filename='Sig.'$LPShort.'.date('YmdHis',time())..docx';
$FullName=$filelocation.'/'.$filename;
//echo$FullName;
$objWriter->save($FullName);
echo$filename;
出口

修复-我不会再次发布所有代码,但此命令将显示解决方案。关键是将定义的样式与addCell命令内联,放在文本的末尾。请注意,上面我只是将addCell与文本放在一起,但后面没有样式。我将发布一个before和after命令来解释:

/*BEFORE* $table->addCell(1600, $table_cell_style)->addText("{$full_name_title}");

/*AFTER*/ $table->addCell(1600, $table_cell_style)->addText("{$full_name_title}", $BodyFontStyle);