File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ <#
2+ . SYNOPSIS
3+ Gets word file styles
4+ . DESCRIPTION
5+ Gets the `/word/styles.xml` within a Word File.
6+ #>
7+ [OutputType ([xml ])]
8+ param ()
9+
10+ if ($null -ne $this .' #style' ) { return $this .' #style' }
11+
12+ if (-not $this.PartExists ) { return }
13+ if (-not $this.PartExists (' /word/styles.xml' )) { return }
14+
15+ $documentPart = $this.GetPart (' /word/styles.xml' )
16+
17+ $docStream = $documentPart.GetStream ()
18+
19+ $streamReader = [IO.StreamReader ]::new($docStream )
20+
21+ $stylesXml = $streamReader.ReadToEnd () -as [xml ]
22+
23+ $streamReader.Close ()
24+ $streamReader.Dispose ()
25+
26+ $docStream.Close ()
27+ $docStream.Dispose ()
28+
29+ if ($stylesXml ) {
30+ $stylesXml.pstypenames.insert (0 , ' OpenXML.Word.Style' )
31+ $stylesXml.psobject.properties.add (
32+ [psnoteproperty ]::new(' FilePath' , $this.FilePath ), $false
33+ )
34+ $stylesXml.psobject.properties.add (
35+ [psnoteproperty ]::new(' OpenXML' , $this ), $false
36+ )
37+ $stylesXml.psobject.properties.add (
38+ [psnoteproperty ]::new(' Part' , $documentPart ), $false
39+ )
40+ $this.psobject.properties.add (
41+ [psnoteproperty ]::new(' #style' , $stylesXml ), $false
42+ )
43+ return $this .' #styles'
44+ }
45+
You can’t perform that action at this time.
0 commit comments