php - 创建表 - phpword
问题描述
我正在尝试用 phpword 创建一个表。但是我正在努力解决这个表的配置语法。
下面是我的代码:
// Define table style arrays
$styleTable = array('borderSize'=>2, 'cellMargin'=>10);
$styleFirstRow = array('borderBottomSize'=>5, 'bgColor'=>'#D3D3D3');
// Define cell style arrays
$styleCell = array('valign'=>'center', 'bgColor'=>'#D3D3D3');
$styleCellBTLR = array('valign'=>'center');
// Define font style for first row
$fontStyle = array('bold'=>true, 'align'=>'center');
// Add table style
$wordTest->addTableStyle('CoverLine', $styleTable, $styleFirstRow);
// Add table
$table = $newSection->addTable('CoverLine');
// Add row
// $table->addRow(200);
// Add cells
// $table->addCell(10000, $styleCell)->addText('Employer Details ', $fontStyle);
//$table->addCell(1800)->addText($curriculum->curriculum_code);
$table->addRow(500);
$table->addCell(2200, $styleCell)->addText(' Code', $fontStyle);
$table->addCell(5000, $styleCell)->addText(' Title', $fontStyle);
$table->addRow(500);
$table->addCell(2200)->addText('', $fontStyle);
$table->addCell(5000)->addText('', $fontStyle);
$table->addRow(500);
$table->addCell(2200, $styleCell)->addText('', $fontStyle);
$table->addCell(1200, $styleCell)->addText(' Name', $fontStyle);
$table->addCell(2500, $styleCell)->addText(' Email', $fontStyle);
$table->addCell(2000, $styleCell)->addText(' Phone', $fontStyle);
$table->addCell(2000, $styleCell)->addText(' Logo', $fontStyle);
$table->addRow(600);
$table->addCell(700, $styleCell)->addText(' Development Quality Partner', $fontStyle);
$table->addCell(2000)->addText('');
$table->addCell(2000)->addText('');
$table->addCell(2000)->addText('');
$table->addCell(2000)->addText('');
我得到的与刺激太大不同。请协助。我已经浏览了 phpword 文档,似乎我遗漏了一些东西。
解决方案
表格网格不适用于仅使用单元格宽度来实现跨越多列或多行的单元格;需要明确定义跨越多列和多行的单元格。
您可以在How to make the table in word using PHPWord 中找到另一个类似的问题和答案示例,其中包括多个行跨度和列跨度?
推荐阅读
- caching - 前端与后端分离
- c++ - 使用可变类模板类型的成员函数的结果初始化数组?
- java - Android UDP返回随机字符
- php - PHP函数来适应texte不使用特殊字符?
- azure-active-directory - 如何请求访问 Microsoft Graph Explorer?
- c# - C# 从基方法返回
- cmake - 应用程序代码外部的 CMake protobuf
- mysql - 2 来自同一张表的嵌套查询?
- laravel - (正确)从 AWS 服务器中删除 Laravel 应用程序而不删除实例
- python - 需要帮助解决python中关于数字和回文的某个问题