Create single row and properites word table
#Create word table for Single Row With Header
#returns last row position used by this table
function CreateSingleRowTable
{
param([object]$selection,
[object]$document,
[string]$startPosition,
[array]$values,
[bool]$useBold,
[bool]$terminate
)
$rows=1
$columns=$values.Length
$range = $selection.Range
$table=$document.Tables.add($range,$rows,$columns)
for($i=1; $i -le $columns; $i++)
{
if($useBold -eq $true)
{
$table.Cell($startPosition,$i).Range.Font.Bold = $true
}
$table.cell($startPosition,$i).range.text = $values[$i-1]
}
$table.Borders.Enable=$true
#end table and enter new line
$selection.EndKey(6)
if($terminate -eq $true)
{
$selection.TypeParagraph()
}
return $startPosition + $rows
}
#Create additional word table for Web part properties - generic version
#returns last row position used by this table
function CreatePropertiesTable
{
param([object]$selection,
[object]$document,
[int]$lastPreviousRow,
[array]$properties,
[bool]$terminate,
[bool]$firstRowBold
)
$rows=$properties.Length
$columns=2
$lastRowPosition=$lastPreviousRow+1+$rows
$range = $selection.Range
$table=$document.Tables.add($range,$rows,$columns)
$table.Borders.Enable=$true
#set defaults
$defaultText="not set"
if($firstRowBold -eq $true)
{
$table.cell($lastPreviousRow+1 ,1).range.Font.Bold = $true
$table.cell($lastPreviousRow+1 ,2).range.Font.Bold = $true
}
$i = $lastPreviousRow #because previous WP table has 7 rows $rows+1
foreach($property in $properties)
{
#$listName = SetDefaultText -parameter $listName -defaultText $defaultText
$property.Value = SetDefaultText -parameter $property.Value -defaultText $defaultText
$table.cell($i+1 ,1).range.text=$property.Name
$table.cell($i+1 ,2).range.text=$property.Value
$i++
}
#end table
$selection.EndKey(6)
if($terminate -eq $true)
{
$selection.TypeParagraph()
}
return $lastRowPosition
}
#Set default text to empty parameter
function SetDefaultText
{
param([string]$parameter, [string]$defaultText)
if([string]::IsNullOrEmpty($parameter))
{
return $defaultText
}
else
{
return $parameter
}
}