Skip to content

Commit b375b85

Browse files
committed
fix broken samples
1 parent 54e7c6d commit b375b85

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

samples/Sample_11_ReadWord97.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@
77
echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
88
$phpWord = \PhpOffice\PhpWord\IOFactory::load($source, 'MsDoc');
99

10-
// (Re)write contents
11-
$writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf');
12-
foreach ($writers as $writer => $extension) {
13-
echo date('H:i:s'), " Write to {$writer} format", EOL;
14-
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer);
15-
$xmlWriter->save("{$name}.{$extension}");
16-
rename("{$name}.{$extension}", "results/{$name}.{$extension}");
10+
// Save file
11+
echo write($phpWord, basename(__FILE__, '.php'), $writers);
12+
if (!CLI) {
13+
include_once 'Sample_Footer.php';
1714
}
18-
19-
include_once 'Sample_Footer.php';

samples/Sample_23_TemplateBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
echo date('H:i:s'), ' Saving the result document...', EOL;
1515
$templateProcessor->saveAs('results/Sample_23_TemplateBlock.docx');
1616

17-
echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_23_TemplateBlock.docx');
17+
echo getEndingNotes(array('Word2007' => 'docx'), 'Sample_23_TemplateBlock');
1818
if (!CLI) {
1919
include_once 'Sample_Footer.php';
2020
}

samples/resources/Sample_30_ReadHTML.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ <h1>Adding element via HTML</h1>
1717
<h2>Includes images</h2>
1818
<img src="https://phpword.readthedocs.io/en/latest/_images/phpword.png" alt=""/>
1919

20-
<img src="https://localhost/gev/desarrollo/actividades/pruebas_14/5b064503587f7.jpeg" name="Imagen 12" align="bottom" width="208" height="183" border="0"/>
21-
<img src="http://localhost/gev/desarrollo/actividades/pruebas_14/5b064503589db.png" name="Imagen 13" align="bottom" width="143" height="202" border="0"/>
22-
<img src="http://localhost/gev/desarrollo/actividades/pruebas_14/5b0645035aac8.jpeg" name="Imagen 14" align="bottom" width="194" height="188" border="0"/>
20+
<img src="http://php.net/images/logos/php-med-trans-light.gif" name="Imagen 12" align="bottom" width="208" height="183" border="0"/>
21+
<img src="http://php.net/images/logos/php-icon.png" name="Imagen 13" align="bottom" width="143" height="202" border="0"/>
22+
<img src="http://php.net/images/logos/php-med-trans-light.gif" name="Imagen 14" align="bottom" width="194" height="188" border="0"/>
2323

2424
</body>
2525
</html>

src/PhpWord/Writer/HTML/Element/Table.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,23 @@ public function write()
107107
/**
108108
* Translates Table style in CSS equivalent
109109
*
110-
* @param \PhpOffice\PhpWord\Style\Table|null $tableStyle
110+
* @param string|\PhpOffice\PhpWord\Style\Table|null $tableStyle
111111
* @return string
112112
*/
113-
private function getTableStyle(\PhpOffice\PhpWord\Style\Table $tableStyle = null)
113+
private function getTableStyle($tableStyle = null)
114114
{
115115
if ($tableStyle == null) {
116116
return '';
117117
}
118-
$style = ' style="';
119-
if ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_FIXED) {
120-
$style .= 'table-layout: fixed;';
121-
} elseif ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_AUTO) {
122-
$style .= 'table-layout: auto;';
118+
if (is_string($tableStyle)) {
119+
$style = ' class="' . $tableStyle;
120+
} else {
121+
$style = ' style="';
122+
if ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_FIXED) {
123+
$style .= 'table-layout: fixed;';
124+
} elseif ($tableStyle->getLayout() == \PhpOffice\PhpWord\Style\Table::LAYOUT_AUTO) {
125+
$style .= 'table-layout: auto;';
126+
}
123127
}
124128

125129
return $style . '"';

0 commit comments

Comments
 (0)