Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemyslawKlys committed Sep 21, 2020
1 parent 5eb348d commit 7561972
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 186 deletions.
32 changes: 32 additions & 0 deletions Examples/Example-Table12.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

$InvoiceEntry7 = [ordered]@{}
$InvoiceEntry7.Description = 'IT Services 4'
$InvoiceEntry7.Amount = '$301'

$InvoiceEntry8 = [ordered]@{}
$InvoiceEntry8.Description = 'IT Services 5'
$InvoiceEntry8.Amount = '$299'

$InvoiceDataOrdered1 = @(
$InvoiceEntry7
)
$InvoiceDataOrdered2 = @(
$InvoiceEntry7
$InvoiceEntry8
)


#Import-Module PSWriteWord #-Force
$FilePath = "$Env:USERPROFILE\Desktop\PSWriteWord-Example-Tables11.docx"

$WordDocument = New-WordDocument $FilePath
Add-WordTable -WordDocument $WordDocument -DataTable $InvoiceDataOrdered1 -Design ColorfulGrid -Supress $true -Transpose
Add-WordParagraph -WordDocument $WordDocument -Supress $True

# Notice Supress $false
$Table = Add-WordTable -WordDocument $WordDocument -DataTable $InvoiceDataOrdered2 -Design ColorfulGrid -Percentage $true -Transpose -Supress $false

# First row height set to 500
$Table.Rows[0].Height = 500

Save-WordDocument $WordDocument -Language 'en-US' -Supress $True -OpenDocument
51 changes: 40 additions & 11 deletions PSWriteWord.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
$PSVersionTable.PSVersion

$ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName

if ($null -eq (Get-Module -ListAvailable pester)) {
Write-Warning "$ModuleName - Downloading Pester from PSGallery"
Install-Module -Name Pester -Repository PSGallery -Force -SkipPublisherCheck
$PrimaryModule = Get-ChildItem -Path $PSScriptRoot -Filter '*.psd1' -Recurse -ErrorAction SilentlyContinue -Depth 1
if (-not $PrimaryModule) {
throw "Path $PSScriptRoot doesn't contain PSD1 files. Failing tests."
}
if ($null -eq (Get-Module -ListAvailable PSSharedGoods)) {
Write-Warning "$ModuleName - Downloading PSSharedGoods from PSGallery"
Install-Module -Name PSSharedGoods -Repository PSGallery -Force
if ($PrimaryModule.Count -ne 1) {
throw 'More than one PSD1 files detected. Failing tests.'
}
$PSDInformation = Import-PowerShellDataFile -Path $PrimaryModule.FullName
$RequiredModules = @(
'Pester'
'PSWriteColor'
if ($PSDInformation.RequiredModules) {
$PSDInformation.RequiredModules
}
)
foreach ($Module in $RequiredModules) {
if ($Module -is [System.Collections.IDictionary]) {
$Exists = Get-Module -ListAvailable -Name $Module.ModuleName
if (-not $Exists) {
Write-Warning "$ModuleName - Downloading $($Module.ModuleName) from PSGallery"
Install-Module -Name $Module.ModuleName -Force -SkipPublisherCheck
}
} else {
$Exists = Get-Module -ListAvailable $Module -ErrorAction SilentlyContinue
if (-not $Exists) {
Install-Module -Name $Module -Force -SkipPublisherCheck
}
}
}

Import-Module PSSharedGoods -Force
Import-Module $PSScriptRoot\PSWriteWord.psd1 -Force
Write-Color 'ModuleName: ', $ModuleName, ' Version: ', $PSDInformation.ModuleVersion -Color Yellow, Green, Yellow, Green -LinesBefore 2
Write-Color 'PowerShell Version: ', $PSVersionTable.PSVersion -Color Yellow, Green
Write-Color 'PowerShell Edition: ', $PSVersionTable.PSEdition -Color Yellow, Green
Write-Color 'Required modules: ' -Color Yellow
foreach ($Module in $PSDInformation.RequiredModules) {
if ($Module -is [System.Collections.IDictionary]) {
Write-Color ' [>] ', $Module.ModuleName, ' Version: ', $Module.ModuleVersion -Color Yellow, Green, Yellow, Green
} else {
Write-Color ' [>] ', $Module -Color Yellow, Green
}
}
Write-Color

Import-Module $PSScriptRoot\*.psd1 -Force
$result = Invoke-Pester -Script $PSScriptRoot\Tests -Verbose -EnableExit

if ($result.FailedCount -gt 0) {
Expand Down
188 changes: 22 additions & 166 deletions PSWriteWord.psd1
Original file line number Diff line number Diff line change
@@ -1,171 +1,27 @@
#
# Module manifest for module 'PSWriteWord'
#
# Generated by: Przemyslaw Klys
#
# Generated on: 03.06.2020
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'PSWriteWord.psm1'

# Version number of this module.
ModuleVersion = '1.1.8'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '6314c78a-d011-4489-b462-91b05ec6a5c4'

# Author of this module
Author = 'Przemyslaw Klys'

# Company or vendor of this module
CompanyName = 'Evotec'

# Copyright statement for this module
Copyright = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Simple project to create Microsoft Word in PowerShell without having Office installed.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.1'

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'PSSharedGoods'; GUID = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'; ModuleVersion = '0.0.145'; })

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Get-WordBookmark', 'Set-WordBookmark', 'New-WordBlock',
'New-WordBlockList', 'New-WordBlockPageBreak',
'New-WordBlockParagraph', 'New-WordBlockTable', 'Add-WordBarChart',
'Add-WordChartSeries', 'Add-WordLineChart', 'Add-WordPieChart',
'Documentimo', 'DocChart', 'DocList', 'DocListItem', 'DocNumbering',
'DocPageBreak', 'DocTable', 'DocText', 'DocToc', 'Add-WordFooter',
'Add-WordHeader', 'Get-WordFooter', 'Get-WordHeader',
'Add-WordHyperLink', 'Add-WordList', 'Add-WordListItem',
'Convert-ListToHeadings', 'New-WordList', 'New-WordListItem',
'New-WordListItemInternal', 'Set-WordList', 'Get-WordDocument',
'Merge-WordDocument', 'New-WordDocument', 'Save-WordDocument',
'Add-WordCustomProperty', 'Add-WordEquation', 'Add-WordLine',
'Add-WordPageCount', 'Add-WordProtection', 'Add-WordSection',
'Add-WordTabStopPosition', 'Get-WordCustomProperty',
'Get-WordPageSettings', 'Get-WordSection', 'Set-WordMargins',
'Set-WordOrientation', 'Set-WordPageSettings', 'Set-WordPageSize',
'Add-WordPageBreak', 'Add-WordParagraph', 'Add-WordText',
'Get-WordListItemParagraph', 'Get-WordParagraphs',
'Get-WordParagraphForList', 'Remove-WordParagraph', 'Remove-WordText',
'Set-WordParagraph', 'Set-WordText', 'Set-WordTextAlignment',
'Set-WordTextBold', 'Set-WordTextCapsStyle', 'Set-WordTextColor',
'Set-WordTextDirection', 'Set-WordTextFontFamily',
'Set-WordTextFontSize', 'Set-WordTextHeadingType',
'Set-WordTextHidden', 'Set-WordTextHighlight',
'Set-WordTextIndentationFirstLine',
'Set-WordTextIndentationHanging', 'Set-WordTextItalic',
'Set-WordTextKerning', 'Set-WordTextLanguage', 'Set-WordTextMisc',
'Set-WordTextPercentageScale', 'Set-WordTextPosition',
'Set-WordTextReplace', 'Set-WordTextScript',
'Set-WordTextShadingType', 'Set-WordTextSpacing',
'Set-WordTextSpacingAfter', 'Set-WordTextSpacingBefore',
'Set-WordTextStrikeThrough', 'Set-WordTextUnderlineColor',
'Set-WordTextUnderlineStyle', 'Add-WordPicture', 'Get-WordPicture',
'Remove-WordPicture', 'Set-WordPicture', 'Add-WordTable',
'Add-WordTableCellValue', 'Add-WordTableColumn', 'Add-WordTableRow',
'Add-WordTableTitle', 'Copy-WordTableRow', 'Get-WordTable',
'Get-WordTableRow', 'New-WordTable', 'New-WordTableBorder',
'Remove-WordTable', 'Remove-WordTableColumn', 'Remove-WordTableRow',
'Set-WordTable', 'Set-WordTableAutoFit', 'Set-WordTableBorder',
'Set-WordTableCell', 'Set-WordTableCellFillColor',
'Set-WordTableCellShadingColor', 'Set-WordTableColumnWidth',
'Set-WordTableColumnWidthByIndex', 'Set-WordTableDesign',
'Set-WordTableDirection', 'Set-WordTablePageBreak',
'Set-WordTableRowMergeCells', 'Add-WordTOC', 'Add-WordTocItem'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()

# Variables to export from this module
# VariablesToExport = @()

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = 'Doc', 'New-Documentimo', 'DocumentimoChart', 'New-DocumentimoChart',
'DocumentimoList', 'New-DocumentimoList', 'DocumentimoListItem',
'New-DocumentimoListItem', 'DocumentimoNumbering',
'New-DocumentimoNumbering', 'DocumentimoPageBreak',
'New-DocumentimoPageBreak', 'DocumentimoTable',
'New-DocumentimoTable', 'DocumentimoText', 'New-DocumentimoText',
'DocumentimoTOC', 'New-DocumentimoTOC', 'Add-WordPageNumber'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

@{
AliasesToExport = @('Doc', 'New-Documentimo', 'DocumentimoChart', 'New-DocumentimoChart', 'DocumentimoList', 'New-DocumentimoList', 'DocumentimoListItem', 'New-DocumentimoListItem', 'DocumentimoNumbering', 'New-DocumentimoNumbering', 'DocumentimoPageBreak', 'New-DocumentimoPageBreak', 'DocumentimoTable', 'New-DocumentimoTable', 'DocumentimoText', 'New-DocumentimoText', 'DocumentimoTOC', 'New-DocumentimoTOC', 'Add-WordPageNumber')
Author = 'Przemyslaw Klys'
CmdletsToExport = @()
CompanyName = 'Evotec'
CompatiblePSEditions = @('Desktop')
Copyright = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.'
Description = 'Simple project to create Microsoft Word in PowerShell without having Office installed.'
FunctionsToExport = @('Get-WordBookmark', 'Set-WordBookmark', 'New-WordBlock', 'New-WordBlockList', 'New-WordBlockPageBreak', 'New-WordBlockParagraph', 'New-WordBlockTable', 'Add-WordBarChart', 'Add-WordChartSeries', 'Add-WordLineChart', 'Add-WordPieChart', 'Documentimo', 'DocChart', 'DocList', 'DocListItem', 'DocNumbering', 'DocPageBreak', 'DocTable', 'DocText', 'DocToc', 'Add-WordFooter', 'Add-WordHeader', 'Get-WordFooter', 'Get-WordHeader', 'Add-WordHyperLink', 'Add-WordList', 'Add-WordListItem', 'Convert-ListToHeadings', 'New-WordList', 'New-WordListItem', 'New-WordListItemInternal', 'Set-WordList', 'Get-WordDocument', 'Merge-WordDocument', 'New-WordDocument', 'Save-WordDocument', 'Add-WordCustomProperty', 'Add-WordEquation', 'Add-WordLine', 'Add-WordPageCount', 'Add-WordProtection', 'Add-WordSection', 'Add-WordTabStopPosition', 'Get-WordCustomProperty', 'Get-WordPageSettings', 'Get-WordSection', 'Set-WordMargins', 'Set-WordOrientation', 'Set-WordPageSettings', 'Set-WordPageSize', 'Add-WordPageBreak', 'Add-WordParagraph', 'Add-WordText', 'Get-WordListItemParagraph', 'Get-WordParagraphs', 'Get-WordParagraphForList', 'Remove-WordParagraph', 'Remove-WordText', 'Set-WordParagraph', 'Set-WordText', 'Set-WordTextAlignment', 'Set-WordTextBold', 'Set-WordTextCapsStyle', 'Set-WordTextColor', 'Set-WordTextDirection', 'Set-WordTextFontFamily', 'Set-WordTextFontSize', 'Set-WordTextHeadingType', 'Set-WordTextHidden', 'Set-WordTextHighlight', 'Set-WordTextIndentationFirstLine', 'Set-WordTextIndentationHanging', 'Set-WordTextItalic', 'Set-WordTextKerning', 'Set-WordTextLanguage', 'Set-WordTextMisc', 'Set-WordTextPercentageScale', 'Set-WordTextPosition', 'Set-WordTextReplace', 'Set-WordTextScript', 'Set-WordTextShadingType', 'Set-WordTextSpacing', 'Set-WordTextSpacingAfter', 'Set-WordTextSpacingBefore', 'Set-WordTextStrikeThrough', 'Set-WordTextUnderlineColor', 'Set-WordTextUnderlineStyle', 'Add-WordPicture', 'Get-WordPicture', 'Remove-WordPicture', 'Set-WordPicture', 'Add-WordTable', 'Add-WordTableCellValue', 'Add-WordTableColumn', 'Add-WordTableRow', 'Add-WordTableTitle', 'Copy-WordTableRow', 'Get-WordTable', 'Get-WordTableRow', 'New-WordTable', 'New-WordTableBorder', 'Remove-WordTable', 'Remove-WordTableColumn', 'Remove-WordTableRow', 'Set-WordTable', 'Set-WordTableAutoFit', 'Set-WordTableBorder', 'Set-WordTableCell', 'Set-WordTableCellFillColor', 'Set-WordTableCellShadingColor', 'Set-WordTableColumnWidth', 'Set-WordTableColumnWidthByIndex', 'Set-WordTableDesign', 'Set-WordTableDirection', 'Set-WordTablePageBreak', 'Set-WordTableRowMergeCells', 'Add-WordTOC', 'Add-WordTocItem')
GUID = '6314c78a-d011-4489-b462-91b05ec6a5c4'
ModuleVersion = '1.1.9'
PowerShellVersion = '5.1'
PrivateData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'word', 'docx', 'write', 'PSWord', 'office', 'windows', 'doc'

# A URL to the license for this module.
Tags = @('word', 'docx', 'write', 'PSWord', 'office', 'windows', 'doc')
LicenseUri = 'https://github.com/EvotecIT/PSWriteWord/blob/master/License'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/EvotecIT/PSWriteWord'

# A URL to an icon representing this module.
IconUri = 'https://evotec.xyz/wp-content/uploads/2018/10/PSWriteWord.png'

# ReleaseNotes of this module
# ReleaseNotes = ''

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}
}
RequiredModules = @(@{
ModuleVersion = '0.0.180'
ModuleName = 'PSSharedGoods'
Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'
})
RootModule = 'PSWriteWord.psm1'
}
19 changes: 10 additions & 9 deletions Public/Paragraph/Set-WordTextReplace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,21 @@
[parameter(ValueFromPipelineByPropertyName, ValueFromPipeline)][Xceed.Document.NET.InsertBeforeOrAfter] $Paragraph,
[string] $SearchValue,
[string] $ReplaceValue,
[bool] $TrackChanges,
[switch] $TrackChanges,
[System.Text.RegularExpressions.RegexOptions] $RegexOptions,
[Xceed.Document.NET.Formatting] $NewFormatting,
[Xceed.Document.NET.Formatting] $MatchFormatting,
[Xceed.Document.NET.MatchFormattingOptions] $MatchFormattingOptions,
[bool] $escapeRegEx = $true,
[bool] $useRegExSubstitutions = $false,
[bool] $removeEmptyParagraph = $true
[switch] $EscapeRegEx,
[switch] $UseRegExSubstitutions,
[switch] $RemoveEmptyParagraph,
[alias('Supress')][bool] $Suppress = $false
)
#void ReplaceText(string searchValue, string newValue, bool trackChanges, System.Text.RegularExpressions.RegexOptions options, Xceed.Document.NET.Formatting newFormatting, Xceed.Document.NET.Formatting matchFormatting, Xceed.Document.NET.MatchFormattingOptions fo, bool escapeRegEx, bool useRegExSubstitutions, bool removeEmptyParagraph)
#void ReplaceText(string findPattern, System.Func[string,string] regexMatchHandler, bool trackChanges, System.Text.RegularExpressions.RegexOptions options, Xceed.Document.NET.Formatting newFormatting, Xceed.Document.NET.Formatting matchFormatting, Xceed.Document.NET.MatchFormattingOptions fo, bool removeEmptyParagraph)

$Paragraph.ReplaceText
if ($Paragraph) {
$Paragraph = $Paragraph.ReplaceText($SearchValue, $ReplaceValue, $TrackChanges.IsPresent, $RegexOptions, $NewFormatting, $matchFormatting, $MatchFormattingOptions, $EscapeRegEx.IsPresent, $UseRegExSubstitutions.IsPresent, $RemoveEmptyParagraph.IsPresent)
if ($Supress) { return } else { return $Paragraph }
}
#$Paragraph.ReplaceText($SearchValue, $ReplaceValue, $TrackChanges, $RegexOptions, $NewFormatting, $MatchFormatting, $MatchFormattingOptions, $escapeRegEx, $useRegExSubstitutions, $removeEmptyParagraph)
}

#Set-WordTextReplace
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ _PSWriteWord_ is PowerShell module to create Microsoft Word documents without Mi

## Updates

- 1.1.9 - 2020.09.21
- [x] Fixes `Set-WordTextReplace` that would not work at all
- [x] Updates PSD1
- 1.1.8 - 3.06.2020
- Fixes `Transpose` parameter for `Add-WordTable` giving wrong order [#44](https://github.com/EvotecIT/PSWriteWord/issues/44)

Expand Down

0 comments on commit 7561972

Please sign in to comment.