Skip to content

Commit c5de236

Browse files
feat: OpenXML.Word.File/Document.get_Table ( Fixes #45 )
1 parent 36437b1 commit c5de236

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<#
2+
.SYNOPSIS
3+
Gets tables in a document
4+
.DESCRIPTION
5+
Gets any table elements within a Word document.
6+
#>
7+
$doc = $this
8+
if ($doc -isnot [xml]) { return }
9+
foreach ($wordTable in
10+
$doc |
11+
Select-Xml -XPath '//w:tbl' -Namespace @{w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
12+
) {
13+
$table = $wordTable.Node
14+
if ($table.pstypenames[0] -ne 'OpenXML.Word.Table') {
15+
$table.pstypenames.insert(0, 'OpenXML.Word.Table')
16+
}
17+
if (-not $table.FilePath) {
18+
$table.psobject.properties.add(
19+
[psnoteproperty]::new("FilePath", $this.FilePath), $false
20+
)
21+
}
22+
if (-not $table.OpenXML) {
23+
$table.psobject.properties.add(
24+
[psnoteproperty]::new("OpenXML", $this.OpenXML), $false
25+
)
26+
}
27+
$table
28+
}
29+
30+
31+
32+
33+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
return $this.Document.Table

0 commit comments

Comments
 (0)