@@ -21,42 +21,44 @@ A post-alpha release is expected within a few weeks, say Feb 1, 2014.
2121What it can do
2222--------------
2323
24+ .. |img | image :: /_static/img/example-docx-01.png
25+
2426Here's an example of what |docx | can do:
2527
26- .. figure :: /_static/img/example-docx-01.png
28+ ====== ======================================================================
29+ |img | ::
30+
31+ from docx import Document
2732
28- |
33+ document = Document()
2934
30- ::
35+ document.add_heading('Document Title', 0)
36+ document.add_paragraph('A plain paragraph.')
3137
32- from docx import Document
38+ document.add_heading('Heading, level 1', level=1)
39+ document.add_paragraph('Intense quote', style='IntenseQuote')
3340
34- document = Document()
41+ document.add_bullet('first item in unordered list')
42+ document.add_list_item('first item in ordered list')
3543
36- document.add_heading('Document Title', 0)
37- document.add_paragraph('A plain paragraph.')
38- document.add_heading('Heading, level 1', level=1)
39- document.add_paragraph('Intense quote', style='IntenseQuote')
40- document.add_bullet('first item in unordered list')
41- document.add_list_item('first item in ordered list')
44+ document.add_picture('monty-truth.png')
4245
43- document.add_picture('monty-truth.png')
46+ table = document.add_table(rows=1, cols=3)
47+ table.style = 'LightShading-Accent1'
48+ header_cells = table.rows[0].cells
49+ header_cells[0].text = 'Qty'
50+ header_cells[1].text = 'Id'
51+ header_cells[2].text = 'Desc'
52+ for item in recordset:
53+ row_cells = table.add_row().cells
54+ row_cells[0].text = str(item.qty)
55+ row_cells[1].text = str(item.id)
56+ row_cells[2].text = item.desc
4457
45- table = document.add_table(rows=1, cols=3)
46- table.style = 'LightShading-Accent1'
47- header_cells = table.rows[0].cells
48- header_cells[0].text = 'Qty'
49- header_cells[1].text = 'Id'
50- header_cells[2].text = 'Desc'
51- for item in recordset:
52- row_cells = table.add_row().cells
53- row_cells[0].text = str(item.qty)
54- row_cells[1].text = str(item.id)
55- row_cells[2].text = item.desc
56-
57- document.add_page_break()
58+ document.add_page_break()
5859
59- document.save('demo.docx')
60+ document.save('demo.docx')
61+ ====== ======================================================================
6062
6163
6264User Guide
@@ -70,6 +72,7 @@ User Guide
7072 user/api-concepts
7173 user/styles
7274 user/tables
75+ user/shapes
7376 user/text
7477
7578
0 commit comments