我正在努力在 PHPPowerpoint 中设置单元格的对齐方式,我已经搜索和搜索,似乎找不到任何东西
这是我的 PHP PowerPoint 构建脚本的片段 -
$shape = $currentSlide->createTableShape(14);
$shape->setHeight(100);
$shape->setWidth(800);
$shape->setOffsetX(50);
$shape->setOffsetY(200);
echo date('H:i:s') . ' Add Header Row'.EOL;
$row = $shape->createRow()->setHeight(15);
$row->nextCell()->setWidth(75)->createTextRun('')->getFont()->setBold(true)->setSize(11);
$row->nextCell()->setColSpan(6)->createTextRun('Tests')->getFont()->setBold(true)->setSize(11);
$row->getCell()->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_BOTTOM); // trying to set alignment here
$row->nextCell()->createTextRun('');
$row->nextCell()->createTextRun('');
$row->nextCell()->createTextRun('');
$row->nextCell()->createTextRun('');
$row->nextCell()->createTextRun('');
$row->nextCell()->setColSpan(6)->createTextRun('Long Tests')->getFont()->setBold(true)->setSize(11);
$row->nextCell()->createTextRun('');
$row->nextCell()->createTextRun('');
$row->nextCell()->createTextRun('');
$row->nextCell()->createTextRun('');
$row->nextCell()->createTextRun('');
$row->nextCell()->setWidth(75)->createTextRun('XTests')->getFont()->setBold(true)->setSize(11);
我尝试将对齐设置为与单元格的文本创建内联,如下所示 -
$row->nextCell()->setColSpan(6)->createTextRun('Tests')->getFont()->setBold(true)->setSize(11)->getCell()->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_BOTTOM);
这会引发一个错误,指出字体类中不存在对齐,公平地说它不存在,但我似乎无法以更好的方式进入对齐。
其次,我尝试在单元格中创建文本后直接包含对齐代码 -
$row->getCell()->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setVertical(Alignment::VERTICAL_BOTTOM); // trying to set alignment here
这似乎运行,但对已生成的幻灯片没有任何影响。
任何建议都非常感谢!