Skip to content

Commit 280d46a

Browse files
author
Steve Canny
committed
fix: python-openxml#149 KeyError on Document.add_table()
1 parent 5309b41 commit 280d46a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Release History
44
---------------
55

6+
NEXT
7+
++++++++++++++++++
8+
9+
- Fix #149: KeyError on Document.add_table()
10+
11+
612
0.8.4 (2015-02-20)
713
++++++++++++++++++
814

docx/document.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,12 @@ def add_section(self, start_type=WD_SECTION.NEW_PAGE):
8989
new_sectPr.start_type = start_type
9090
return Section(new_sectPr)
9191

92-
def add_table(self, rows, cols, style='Light Shading Accent 1'):
92+
def add_table(self, rows, cols, style=None):
9393
"""
9494
Add a table having row and column counts of *rows* and *cols*
95-
respectively and table style of *style*. If *style* is |None|, a
96-
table with no style is produced.
95+
respectively and table style of *style*. *style* may be a paragraph
96+
style object or a paragraph style name. If *style* is |None|, the
97+
table inherits the default table style of the document.
9798
"""
9899
table = self._body.add_table(rows, cols)
99100
table.style = style

features/doc-add-table.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Feature: Add a table
55

66

77
Scenario: Add a table specifying only row and column count
8-
Given a document having built-in styles
8+
Given a blank document
99
When I add a 2 x 2 table specifying only row and column count
1010
Then the document contains a 2 x 2 table
11-
And table.style is styles['Light Shading Accent 1']
11+
And table.style is styles['Normal Table']
1212

1313

1414
Scenario: Add a table specifying style

0 commit comments

Comments
 (0)