Update for 15-03-22 17:30

This commit is contained in:
Tyler Perkins 2022-03-15 17:30:01 -04:00
parent e0a57e6edb
commit 584f4ee015
2 changed files with 47 additions and 0 deletions

View File

@ -4,6 +4,8 @@ Wonderful little scripting language
== Libraries == == Libraries ==
* [[python-docx]]
== Built ins == == Built ins ==
=== Map === === Map ===

45
tech/python-docx.wiki Normal file
View File

@ -0,0 +1,45 @@
= Python docx =
Python docx is a library for generating a .docx file with python code
== Setup ==
{{{
from docx import Document
from docx.shared import Inches
}}}
== Metadata ==
There is document metadata, stored in `Document.core_properties`. Edit these
values to change metadata.
== Functions ==
=== Add headings ===
`add_heading(text, level)`, where text is the text to add, and level is the
size, 0-9, where 0 is the largest.
=== Add paragraphs ===
`add_paragraph(text, style)` where text is the text to add, and style is the
style to apply. Note that `\n`, `\r`, etc work in the text field.
=== Page break ===
`add_page_break()` adds a page break.
== Style ==
=== Lists ===
There are two built in lists, `List Number` and `List Bullet`. `List Number`
incremements each time it is added to a paragraph and creats a numbered list.
Same applied to `List Bullet`.
== Tables ==
Tables are added via the `add_table(rows, cols, style)` function of the
`Document` class.