Skip to content

I copied the code from the documentation and adjusted it to make it run on my computer #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Here's an example of what |docx| can do:
from docx.shared import Inches
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it works without it (I'm not sure how?), we use Inches in the example. I'd suggest we leave it there, because "explicit is better than implicit".


document = Document()

document.add_heading('Document Title', 0)

p = document.add_paragraph('A plain paragraph having some ')
Expand All @@ -46,11 +45,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 = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! Not sure where recordset came from before originally.

{'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()

Expand Down