@@ -14,48 +14,48 @@ What it can do
14
14
15
15
Here's an example of what |docx | can do:
16
16
17
- ====== ======================================================================
18
- |img | ::
19
-
20
- from docx import Document
21
- from docx.shared import Inches
22
-
23
- document = Document()
24
-
25
- document.add_heading('Document Title', 0)
26
-
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
31
-
32
- document.add_heading('Heading, level 1', level=1)
33
- document.add_paragraph('Intense quote', style='IntenseQuote')
34
-
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
- )
41
-
42
- document.add_picture('monty-truth.png', width=Inches(1.25))
43
-
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
54
-
55
- document.add_page_break()
56
-
57
- document.save('demo.docx')
58
- ====== ======================================================================
17
+ ============================================== ===============================================================
18
+ |img | ::
19
+
20
+ from docx import Document
21
+ from docx.shared import Inches
22
+
23
+ document = Document()
24
+
25
+ document.add_heading('Document Title', 0)
26
+
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
31
+
32
+ document.add_heading('Heading, level 1', level=1)
33
+ document.add_paragraph('Intense quote', style='IntenseQuote')
34
+
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
+ )
41
+
42
+ document.add_picture('monty-truth.png', width=Inches(1.25))
43
+
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
54
+
55
+ document.add_page_break()
56
+
57
+ document.save('demo.docx')
58
+ ============================================== ===============================================================
59
59
60
60
61
61
User Guide
0 commit comments