Skip to content

Html writer does not allow hex colors for border-color properties #2856

@Johannes-Werbrouck

Description

@Johannes-Werbrouck

When creating a table, a TableStyle is created with borderColor '006699'. If the table is exported in the Word2007 format, the table borders are blue, as expected. However, when exporting to a HTML format, the table does not get a border-color attribute .

This snippet shows how the table was created, and is taken almost literally from the docs:

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();

$tableStyle = array(
    'borderColor' => '006699',
    'borderSize'  => 6,
    'cellMargin'  => 50
);

$phpWord->addTableStyle('myTable', $tableStyle);
$table = $section->addTable('myTable');

$row = $table->addRow();
$row->addCell();
$row->addCell();
$row->addCell();

$row = $table->addRow();
$row->addCell();
$row->addCell();
$row->addCell();

$phpWord->save('Test.html', 'HTML');

When opening the created Test.html file, I'd expect the myTable css style to have a border-color: #006699 property.

If this is by design (for security reasons maybe?), I can live with the answer and implement a custom solution for my project, where I'm sure the input is not unsafe. If it's not, I'd be happy to create a failing test and supply a PR to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions