Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cedc2e1

Browse files
author
Daniel Rech
committed
Include records in example and remove unused import :)
1 parent 460cae6 commit cedc2e1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

docs/index.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ Here's an example of what |docx| can do:
1818
|img| ::
1919

2020
from docx import Document
21-
from docx.shared import Inches
2221

2322
document = Document()
24-
2523
document.add_heading('Document Title', 0)
2624

2725
p = document.add_paragraph('A plain paragraph having some ')
@@ -46,11 +44,16 @@ Here's an example of what |docx| can do:
4644
hdr_cells[0].text = 'Qty'
4745
hdr_cells[1].text = 'Id'
4846
hdr_cells[2].text = 'Desc'
47+
recordset = [
48+
{'qty': 1, 'id': 101, 'desc': 'Spam'},
49+
{'qty': 2, 'id': 42, 'desc': 'Eggs'},
50+
{'qty': 3, 'id': 631, 'desc': 'Spam, spam, eggs, and spam'},
51+
]
4952
for item in recordset:
5053
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+
row_cells[0].text = str(item['qty'])
55+
row_cells[1].text = str(item['id'])
56+
row_cells[2].text = item['desc']
5457

5558
document.add_page_break()
5659

0 commit comments

Comments
 (0)