-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path4-listas.php
77 lines (68 loc) · 2.86 KB
/
4-listas.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Trabajar con documentos de Word y PHP usando PHPOffice
*
* Más tutoriales en: parzibyte.me/blog
*
* Ejemplo 4:
* Listas
*/
require_once "vendor/autoload.php";
use PhpOffice\PhpWord\Style\Language;
use PhpOffice\PhpWord\Style\ListItem;
$documento = new \PhpOffice\PhpWord\PhpWord();
$propiedades = $documento->getDocInfo();
$propiedades->setCreator("Luis Cabrera Benito");
$propiedades->setTitle("Listas");
$seccion = $documento->addSection();
$seccion->addListItem("Elemento con profundidad por defecto");
$seccion->addListItem("Elemento con profundidad 1", 1);
$seccion->addListItem("Elemento con profundidad 1", 1);
$seccion->addListItem("Elemento con profundidad 2", 2);
$seccion->addListItem("Elemento con profundidad 2", 2);
$seccion->addListItem("Elemento con profundidad 3", 3);
$seccion->addListItem("Elemento con profundidad 3", 3);
$fuente = [
"name" => "Courier new",
"size" => 20,
"color" => "000000",
"italic" => true,
];
$seccion->addListItem("Elemento con profundidad 1 y con fuente", 1, $fuente);
for ($profundidad = 1; $profundidad < 4; $profundidad++) {
$seccion->addListItem("Elemento con profundidad $profundidad, con fuente y tipo de lista TYPE_SQUARE_FILLED", $profundidad, $fuente, [
'listType' => ListItem::TYPE_SQUARE_FILLED,
]);
}
for ($profundidad = 1; $profundidad < 4; $profundidad++) {
$seccion->addListItem("Elemento con profundidad $profundidad, con fuente y tipo de lista TYPE_BULLET_FILLED", $profundidad, $fuente, [
'listType' => ListItem::TYPE_BULLET_FILLED,
]);
}
for ($profundidad = 1; $profundidad < 4; $profundidad++) {
$seccion->addListItem("Elemento con profundidad $profundidad, con fuente y tipo de lista TYPE_BULLET_EMPTY", $profundidad, $fuente, [
'listType' => ListItem::TYPE_BULLET_EMPTY,
]);
}
for ($profundidad = 1; $profundidad < 4; $profundidad++) {
$seccion->addListItem("Elemento con profundidad $profundidad, con fuente y tipo de lista TYPE_NUMBER", $profundidad, $fuente, [
'listType' => ListItem::TYPE_NUMBER,
]);
}
for ($profundidad = 1; $profundidad < 4; $profundidad++) {
$seccion->addListItem("Elemento con profundidad $profundidad, con fuente y tipo de lista TYPE_NUMBER_NESTED", $profundidad, $fuente, [
'listType' => ListItem::TYPE_NUMBER_NESTED,
]);
}
for ($profundidad = 1; $profundidad < 4; $profundidad++) {
$seccion->addListItem("Elemento con profundidad $profundidad, con fuente y tipo de lista TYPE_ALPHANUM", $profundidad, $fuente, [
'listType' => ListItem::TYPE_ALPHANUM,
]);
}
# Para que no diga que se abre en modo de compatibilidad
$documento->getCompatibility()->setOoxmlVersion(15);
# Idioma español de México
$documento->getSettings()->setThemeFontLang(new Language("ES-MX"));
# Guardarlo
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($documento, "Word2007");
$objWriter->save("4-listas.docx");