forked from OpenXmlDev/Open-Xml-PowerTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpen-XML-PowerTools.psm1
134 lines (107 loc) · 3.89 KB
/
Open-XML-PowerTools.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<#***************************************************************************
Copyright (c) Microsoft Corporation 2014.
This code is licensed using the Microsoft Public License (Ms-PL). The text of the license can be found here:
http://www.microsoft.com/resources/sharedsource/licensingbasics/publiclicense.mspx
Published at http://OpenXmlDeveloper.org
Resource Center and Documentation: http://openxmldeveloper.org/wiki/w/wiki/powertools-for-open-xml.aspx
***************************************************************************#>
<#
Various advanced functions contain prototypical ways of accomplishing certain things:
####################### All Open XML
Get-OpenXmlValidationErrors
- Supports wildcards
- Supports piping a collection of files into it
- Calls a C# function that returns a collection of objects
- Creates a hash table and calls Write-Output
- ValidateSet Parameter (Office version)
Test-OpenXmlValid
- Supports wildcards
- Supports piping a collection of files into it
- Calls a C# function (that returns bool) that was introduced by Add-Type in AddTypes.ps1
- Returns a boolean value
- ValidateSet Parameter (Office version)
AddTypes.ps1
- Add and use C# types
- Link to assemblies when compiling the C#
####################### DOCX
Clear-DocxTrackedRevision
- Supports wildcards
- Supports piping a collection of files into it
- ShouldProcess=$True, ConfirmImpact='Medium'
- Switch parameter (supports -Force)
- Calls directly into OpenXmlPowerTools using WmlDocument
- Defines aliases
Merge-Docx
- Calls directly into OpenXmlPowerTools using WmlDocument
- Defines aliases
- OutputPath parameter
- Returns WmlDocument object
#>
$ver = $PSVersionTable.PSVersion
if ($ver.Major -lt 3) { throw "You must be running PowerShell 3.0 or later" }
if (Get-Module Open-XML-PowerTools) { return }
# AddTypes.ps1 is in the same directory as Open-XML-PowerTools.psm1
# needs to access both Cmdlets and OpenXmlPowerTools
. "$PSScriptRoot\AddTypes.ps1"
. "$PSScriptRoot\Cmdlets\Utils.ps1"
## Applies to any file
. "$PSScriptRoot\Cmdlets\ConvertTo-Base64.ps1"
. "$PSScriptRoot\Cmdlets\ConvertFrom-Base64.ps1"
. "$PSScriptRoot\Cmdlets\ConvertTo-FlatOpc.ps1"
. "$PSScriptRoot\Cmdlets\ConvertFrom-FlatOpc.ps1"
## Applies to all Open XML document types
. "$PSScriptRoot\Cmdlets\Get-OpenXmlValidationErrors.ps1"
. "$PSScriptRoot\Cmdlets\Test-OpenXmlValid.ps1"
. "$PSScriptRoot\Cmdlets\Test-OpenXmlPowerToolsCmdlets.ps1"
# DOCX
. "$PSScriptRoot\Cmdlets\Convert-DocxToHtml.ps1"
. "$PSScriptRoot\Cmdlets\Clear-DocxTrackedRevision.ps1"
. "$PSScriptRoot\Cmdlets\Expand-DocxFormatting.ps1"
. "$PSScriptRoot\Cmdlets\Merge-Docx.ps1"
. "$PSScriptRoot\Cmdlets\Complete-DocxTemplateFromXml.ps1"
. "$PSScriptRoot\Cmdlets\New-Docx.ps1"
. "$PSScriptRoot\Cmdlets\Add-DocxText.ps1"
. "$PSScriptRoot\Cmdlets\New-WmlDocument.ps1"
. "$PSScriptRoot\Cmdlets\DocxLib.ps1"
. "$PSScriptRoot\Cmdlets\Get-DocxMetrics.ps1"
# XLSX
# PPTX
. "$PSScriptRoot\Cmdlets\New-Pptx.ps1"
. "$PSScriptRoot\Cmdlets\Merge-Pptx.ps1"
. "$PSScriptRoot\Cmdlets\PptxLib.ps1"
. "$PSScriptRoot\Cmdlets\New-PmlDocument.ps1"
Export-ModuleMember `
-Alias @(
'AcceptRevision',
'Accept-DocxTrackedRevision',
'BuildDocument',
'BuildPresentation',
'AssembleFormatting'
) `
-Function @(
# All Files
'ConvertTo-Base64',
'ConvertFrom-Base64',
'ConvertTo-FlatOpc',
'ConvertFrom-FlatOpc',
'Convert-DocxToHtml',
'Format-Xml',
# All Open XML
'Get-OpenXmlValidationErrors',
'Test-OpenXmlValid',
'Test-OpenXmlPowerToolsCmdlets',
# DOCX
'Clear-DocxTrackedRevision',
'Expand-DocxFormatting',
'Merge-Docx',
'Complete-DocxTemplateFromXml',
'New-Docx',
'Add-DocxText',
'Get-DocxMetrics',
'New-WmlDocument',
# XLSX
# PPTX
'New-Pptx',
'Merge-Pptx',
'New-PmlDocument'
)