表格不符合OpenOffice / MsWord的宽度

时间:2019-07-15 10:23:02

标签: php laravel ms-word phpword openoffice-writer

我正在尝试在docx文档中创建一些表。 当我使用OpenOffice Writer打开文档时,一切工作都很好,不幸的是,我的表格宽度和其他一些属性在MsWord中没有得到尊重。

1)我创建了两个具有相同大小和相同单元格但未对齐的表

作家

ONE

TWO

代码:

$table = $section->addTable();
$table->addRow(100);
$table->addCell(10000, array( 'borderBottomSize' => 1, 'borderBottomColor' => '000000'))->addText('DISAMINA', array('bold' => true), array('align' => 'center'));
$section->addTextBreak(2);
$table = $section->addTable();
$table->addRow(100);
$table->addCell(4000, array('borderRightSize' => 1, 'borderBottomSize' => 1, 'borderRightColor' => '000000'))->addText('Stato Reale del Rischio', array('bold' => true), array('align' => 'right'));
$htmlWriter::addHtml( $table->addCell(6000, array()),  "<div style='text-align: justify;line-height: 1.5;'>".$appr->relazione->stato_reale_rischio."</div>", false, false);

$table->addRow(100);
$table->addCell(4000, array('borderRightSize' => 1, 'borderBottomSize' => 1, 'borderRightColor' => '000000'))->addText('Dichiarazioni rese dall’Assicurato', array('bold' => true), array('align' => 'right'));
$htmlWriter::addHtml( $table->addCell(6000, array()),  "<div style='text-align: justify;line-height: 1.5;'>".$appr->relazione->dichiarazioni_rese."</div>", false, false);

$table->addRow(100);
$table->addCell(4000, array('borderRightSize' => 1, 'borderBottomSize' => 1, 'borderRightColor' => '000000'))->addText('Meccanica in cui si è svolto il sinistro', array('bold' => true), array('align' => 'right'));
$htmlWriter::addHtml( $table->addCell(6000, array()),  "<div style='text-align: justify;line-height: 1.5;'>".$appr->relazione->meccanica."</div>", false, false);

$table->addRow(100);
$table->addCell(4000, array('borderRightSize' => 1, 'borderBottomSize' => 1, 'borderRightColor' => '000000'))->addText('Caratteristiche mezzi di chiusura', array('bold' => true), array('align' => 'right'));
$htmlWriter::addHtml( $table->addCell(6000, array()),  "<div style='text-align: justify;line-height: 1.5;'>".$appr->relazione->caratteristiche_mezzi."</div>", false, false);

$table->addRow(100);
$table->addCell(4000, array('borderRightSize' => 1, 'borderBottomSize' => 1, 'borderRightColor' => '000000'))->addText('Operatività garanzia', array('bold' => true), array('align' => 'right'));
$htmlWriter::addHtml( $table->addCell(6000, array()),  "<div style='text-align: justify;line-height: 1.5;'>".$appr->relazione->op_garanzia."</div>", false, false);



$section->addTextBreak(2);
$table = $section->addTable();
$table->addRow(100);
$table->addCell(10000, array( 'borderBottomSize' => 1, 'borderBottomColor' => '000000'))->addText('DOCUMENTI ESAMINATI', array('bold' => true), array('align' => 'center'));

$table = $section->addTable();
$table->addRow(100);

$htmlWriter::addHtml( $table->addCell(4000, array('borderRightSize' => 1, 'borderRightColor' => '000000')), '', false, false);
$htmlWriter::addHtml( $table->addCell(6000, array()), "<div style='text-align: justify;line-height: 1.5;'>".$appr->relazione->documenti_esaminati."</div>", false, false);
$section->addTextBreak(2);

$section->addPageBreak();

2)我创建的内容在MsWord中不相同并且宽度不受尊重

作家 Three

msWord

Four

$table = $section->addTable();

$table->addRow(100);
$table->addCell(2000, array('borderRightSize' => 1, 'borderBottomSize' => 1, 'borderRightColor' => '000000'))->addText('Partite Interessate',  array('size' => 10, 'bold'=>true),array('align' => 'right'));
$table->addCell(8000, array())->addText('', $regularFont);

$table->addRow(100);

$table->addCell(2000, array())->addText('',  array('size' => 10, 'bold' => true), array('align' => 'center'));
$table->addCell(2666, array('borderSize' => 1, 'borderColor' => '000000','bgColor'=>'D3D3D3'))->addText('Descrizione',  array('size' => 10, 'bold' => true), array('align' => 'center'));
$table->addCell(2666, array('borderSize' => 1, 'borderColor' => '000000','bgColor'=>'D3D3D3'))->addText('Forma',  array('size' => 10, 'bold' => true), array('align' => 'center'));
$table->addCell(2666, array('borderSize' => 1, 'borderColor' => '000000','bgColor'=>'D3D3D3','gridSpan' => 2))->addText('Capitale Assicurato',  array('size' => 10, 'bold' => true), array('align' => 'center'));

foreach($appr->partiteInteressate as $partita){


$table->addRow(100);
$table->addCell(2000, array())->addText('',  array('size' => 10, 'bold' => true));

$table->addCell(2666, array('borderSize' => 1, 'borderColor' => '000000'))->addText($partita->descrizione,  array('size' => 10, 'bold' => true) ,array('align' => 'left'));
$table->addCell(2666, array('borderSize' => 1, 'borderColor' => '000000'))->addText($partita->forma,  array('size' => 10, 'bold' => true),array('align' => 'center'));
$table->addCell(666, array('borderSize' => 1, 'borderColor' => '000000'))->addText("€.", array('size' => 10, 'bold' => true) ,array('align' => 'left'));
$table->addCell(2000, array('borderSize' => 1, 'borderColor' => '000000'))->addText(number_format($partita->capitale_assicurato ,2, '.', ',') ,  array('size' => 10, 'bold' => true) , array('align' => 'right'));
}

$section->addTextBreak(2);

$table = $section->addTable();

$table->addRow(100);
$table->addCell(2000, array('borderRightSize' => 1, 'borderBottomSize' => 1))->addText('Sottolimiti di Polizza',  array('size' => 10), array('align' => 'left'));
$table->addCell(8000, array())->addText('', $regularFont);

$table->addRow(100);
$table->addCell(2000, array())->addText('', $header, array('align' => 'center'));
$table->addCell(800, array('borderSize' => 1, 'borderColor' => '000000','bgColor'=>'D3D3D3'))->addText('% C.A.',  array('size' => 10, 'bold' => true), array('align' => 'center'));
$table->addCell(2400, array('borderSize' => 1, 'borderColor' => '000000','bgColor'=>'D3D3D3','gridSpan' => 2))->addText('Limite Indennizzo',  array('size' => 10, 'bold' => true), array('align' => 'center'));
$table->addCell(2400, array('borderSize' => 1, 'borderColor' => '000000','bgColor'=>'D3D3D3','gridSpan' => 2))->addText('Franchigia',  array('size' => 10, 'bold' => true), array('align' => 'center'));
$table->addCell(2400, array('borderSize' => 1, 'borderColor' => '000000','bgColor'=>'D3D3D3','gridSpan' => 2))->addText('Indennizzo Massimo',  array('size' => 10, 'bold' => true), array('align' => 'center'));

foreach($appr->garanzieAttivate as $g){


$table->addRow(100);
$table->addCell(2000, array('borderSize' => 1, 'borderColor' => '000000'))->addText($g->descrizione, array('size' => 10), array('align' => 'right'));

$ca = $g->tipologia_limite == 'Percentuale' ?  $g->limite : "" ;

$table->addCell(800, array('borderSize' => 1, 'borderColor' => '000000'))->addText($ca , array('size' => 10, 'bold' => true), array('align' => 'center'));

$table->addCell(466, array('borderSize' => 1, 'borderColor' => '000000'))->addText("€.", array('size' => 10, 'bold' => true) ,array('align' => 'left'));
$table->addCell(1934, array('borderSize' => 1, 'borderColor' => '000000'))->addText(number_format($g->limite_indennizzo ,2, '.', ','), array('size' => 10, 'bold' => true), array('align' => 'right'));
$table->addCell(466, array('borderSize' => 1, 'borderColor' => '000000'))->addText("€.", array('size' => 10, 'bold' => true) ,array('align' => 'left'));
$table->addCell(1934, array('borderSize' => 1, 'borderColor' => '000000'))->addText(number_format($g->franchigia ,2, '.', ','), array('size' => 10, 'bold' => true), array('align' => 'right'));
$table->addCell(466, array('borderSize' => 1, 'borderColor' => '000000'))->addText("€.", array('size' => 10, 'bold' => true) ,array('align' => 'left'));
$table->addCell(1934, array('borderSize' => 1, 'borderColor' => '000000'))->addText(number_format($g->max_indennizzo ,2, '.', ','), array('size' => 10, 'bold' => true), array('align' => 'right'));
}


$section->addPageBreak();

我尝试了许多解决方案\ PhpOffice \ PhpWord \ Style \ Table :: LAYOUT_FIXED,像元宽度等,但是没有一个有效。

感谢您的帮助。

预先感谢

0 个答案:

没有答案