Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions pydocx/export/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ def export_table(self, table):
return self.yield_nested(table.rows, self.export_node)

def export_table_row(self, table_row):
if table_row.is_hidden:
return # skip — row is marked hidden in the docx
return self.yield_nested(table_row.cells, self.export_node)

def export_table_cell(self, table_cell):
Expand Down
1 change: 1 addition & 0 deletions pydocx/openxml/wordprocessing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from pydocx.openxml.wordprocessing.table_row import TableRow
from pydocx.openxml.wordprocessing.text import Text
from pydocx.openxml.wordprocessing.textbox_content import TxBxContent
from pydocx.openxml.wordprocessing.table_row_properties import TableRowProperties # noqa

__all__ = [
'AbstractNum',
Expand Down
15 changes: 11 additions & 4 deletions pydocx/openxml/wordprocessing/table_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
unicode_literals,
)

from pydocx.models import XmlModel, XmlCollection
from pydocx.models import XmlModel, XmlChild, XmlCollection
from pydocx.openxml.wordprocessing.table_cell import TableCell
from pydocx.openxml.wordprocessing.table_row_properties import TableRowProperties # NEW


class TableRow(XmlModel):
XML_TAG = 'tr'

cells = XmlCollection(
TableCell,
)
# NEW: wire in the trPr properties element
properties = XmlChild(type=TableRowProperties)

cells = XmlCollection(TableCell)

@property
def is_hidden(self):
"""Return True if this row has <w:trPr><w:hidden/></w:trPr>."""
return self.properties is not None and self.properties.hidden is not None
17 changes: 17 additions & 0 deletions pydocx/openxml/wordprocessing/table_row_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# coding: utf-8
from __future__ import (
absolute_import,
print_function,
unicode_literals,
)

from pydocx.models import XmlModel, XmlChild


class TableRowProperties(XmlModel):
XML_TAG = 'trPr'

# The presence of <w:hidden/> means the row is hidden.
# XmlChild without attrname returns the raw element if found,
# or None (default) if absent — so bool(hidden) works directly.
hidden = XmlChild(name='hidden')