我尝试使用http://php-odt.sourceforge.net更改表格中所有文字的字体名称。这是代码,
include 'phpodt-0.3/phpodt.php';
$odt = ODT::getInstance();
$table = new Table('table1');
$table->createColumns(3);
$table->addHeader(array('Col 1', 'Col 2', 'Col 3'));
$rows = array(array('1-1', '1-2', '1-3'), array('2-1', '2-2', '2-3'));
$table->addRows($rows);
$odt->output('test_table.odt');
我搜索了documentation of php-odt天堂找不到任何东西。
答案 0 :(得分:0)
我认为你必须做这样的事情:
$tableStyle = new TableStyle('yourcsstablestyle'); //This appears to need to be a style class, where you can set font
$table = new Table('table1', $tableStyle);
以上是未经测试的,但我们可以在PHP-ODT源代码中看到class.table.php
:
class Table {
//Elide member variables
/**
*
* @param DOMDocument $contentDoc The DOMDocument instance of content.xml
* @param TableStyle $tableStyle A TableStyle object representing table style properties
*/
public function __construct($tableName, $tableStyle = null) {
... //more code
您必须传递$tableStyle
值才能使表格具有样式。
TableStyle
类的构造函数如下所示:
public function __construct($name) {
parent::__construct($name);
$this->styleElement->setAttribute('style:family', 'table');
$this->tableProp = $this->contentDocument->createElement('style:table-properties');
$this->styleElement->appendChild($this->tableProp);
}
因此需要将样式类传递给TableStyle
。
文档显示了如何在此处执行paragraph styling,模式似乎相同。