@@ -14,48 +14,48 @@ What it can do
1414
1515Here's an example of what |docx | can do:
1616
17- ====== ======================================================================
18- |img | ::
17+ ============================================ ===============================================================
18+ |img | ::
1919
20- from docx import Document
21- from docx.shared import Inches
20+ from docx import Document
21+ from docx.shared import Inches
2222
23- document = Document()
23+ document = Document()
2424
25- document.add_heading('Document Title', 0)
25+ document.add_heading('Document Title', 0)
2626
27- p = document.add_paragraph('A plain paragraph having some ')
28- p.add_run('bold').bold = True
29- p.add_run(' and some ')
30- p.add_run('italic.').italic = True
27+ p = document.add_paragraph('A plain paragraph having some ')
28+ p.add_run('bold').bold = True
29+ p.add_run(' and some ')
30+ p.add_run('italic.').italic = True
3131
32- document.add_heading('Heading, level 1', level=1)
33- document.add_paragraph('Intense quote', style='IntenseQuote')
32+ document.add_heading('Heading, level 1', level=1)
33+ document.add_paragraph('Intense quote', style='IntenseQuote')
3434
35- document.add_paragraph(
36- 'first item in unordered list', style='ListBullet'
37- )
38- document.add_paragraph(
39- 'first item in ordered list', style='ListNumber'
40- )
35+ document.add_paragraph(
36+ 'first item in unordered list', style='ListBullet'
37+ )
38+ document.add_paragraph(
39+ 'first item in ordered list', style='ListNumber'
40+ )
4141
42- document.add_picture('monty-truth.png', width=Inches(1.25))
42+ document.add_picture('monty-truth.png', width=Inches(1.25))
4343
44- table = document.add_table(rows=1, cols=3)
45- hdr_cells = table.rows[0].cells
46- hdr_cells[0].text = 'Qty'
47- hdr_cells[1].text = 'Id'
48- hdr_cells[2].text = 'Desc'
49- for item in recordset:
50- row_cells = table.add_row().cells
51- row_cells[0].text = str(item.qty)
52- row_cells[1].text = str(item.id)
53- row_cells[2].text = item.desc
44+ table = document.add_table(rows=1, cols=3)
45+ hdr_cells = table.rows[0].cells
46+ hdr_cells[0].text = 'Qty'
47+ hdr_cells[1].text = 'Id'
48+ hdr_cells[2].text = 'Desc'
49+ for item in recordset:
50+ row_cells = table.add_row().cells
51+ row_cells[0].text = str(item.qty)
52+ row_cells[1].text = str(item.id)
53+ row_cells[2].text = item.desc
5454
55- document.add_page_break()
55+ document.add_page_break()
5656
57- document.save('demo.docx')
58- ====== ======================================================================
57+ document.save('demo.docx')
58+ ============================================ ===============================================================
5959
6060
6161User Guide
0 commit comments