From cedc2e1eb063428de150bf7606b9fd9ce5a2bc99 Mon Sep 17 00:00:00 2001 From: Daniel Rech Date: Mon, 7 Apr 2014 12:04:53 +0200 Subject: [PATCH 1/2] Include records in example and remove unused import :) --- docs/index.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 3add723b2..671c0dcc5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,10 +18,8 @@ Here's an example of what |docx| can do: |img| :: from docx import Document - from docx.shared import Inches document = Document() - document.add_heading('Document Title', 0) p = document.add_paragraph('A plain paragraph having some ') @@ -46,11 +44,16 @@ Here's an example of what |docx| can do: hdr_cells[0].text = 'Qty' hdr_cells[1].text = 'Id' hdr_cells[2].text = 'Desc' + recordset = [ + {'qty': 1, 'id': 101, 'desc': 'Spam'}, + {'qty': 2, 'id': 42, 'desc': 'Eggs'}, + {'qty': 3, 'id': 631, 'desc': 'Spam, spam, eggs, and spam'}, + ] for item in recordset: row_cells = table.add_row().cells - row_cells[0].text = str(item.qty) - row_cells[1].text = str(item.id) - row_cells[2].text = item.desc + row_cells[0].text = str(item['qty']) + row_cells[1].text = str(item['id']) + row_cells[2].text = item['desc'] document.add_page_break() From f181a89f1c1651baba6a37399e6bba09769459ae Mon Sep 17 00:00:00 2001 From: Daniel Rech Date: Wed, 9 Nov 2016 10:08:08 +0100 Subject: [PATCH 2/2] Update index.rst --- docs/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.rst b/docs/index.rst index 671c0dcc5..0d137932a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,6 +18,7 @@ Here's an example of what |docx| can do: |img| :: from docx import Document + from docx.shared import Inches document = Document() document.add_heading('Document Title', 0)