Skip to content

Commit

Permalink
Not working, but will be rewritten
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemyslawKlys committed Jan 11, 2022
1 parent 31338bf commit ae018cd
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions Public/New-OfficeWordTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,57 @@
[cmdletBinding()]
param(
[Array] $DataTable,
[DocumentFormat.OpenXml.Wordprocessing.TableLayoutValues] $TableLayout
[DocumentFormat.OpenXml.Wordprocessing.TableLayoutValues] $TableLayout,
[switch] $SkipHeader
)




return

if ($DataTable[0] -is [System.Collections.IDictionary]) {
$Properties = 'Name', 'Value'
} else {
$Properties = Select-Properties -Objects $DataTable -AllProperties:$AllProperties -Property $IncludeProperty -ExcludeProperty $ExcludeProperty
}

$Table = [DocumentFormat.OpenXml.Wordprocessing.Table]::new()
# $Table = [DocumentFormat.OpenXml.Wordprocessing.Table]::new()
$Table = [DocumentFormat.OpenXml.Wordprocessing.TableGrid]::new()

$TableProperties = [DocumentFormat.OpenXml.Wordprocessing.TableProperties]::new()


#TextWrappingValues tableTextWrapping = TextWrappingValues.Around;

$TableProperties.TableLayout = [DocumentFormat.OpenXml.Wordprocessing.TableLayout] @{
Type = $TableLayout #[DocumentFormat.OpenXml.Wordprocessing.TableLayoutValues]::Autofit
}
#$TableProperties.TableLayout = [DocumentFormat.OpenXml.Wordprocessing.TableLayout] @{
# Type = $TableLayout #[DocumentFormat.OpenXml.Wordprocessing.TableLayoutValues]::Autofit
#}
# $TableProperties.TableWidth = [DocumentFormat.OpenXml.Wordprocessing.TableWidth] @{
# Width = "0"
# Type = [DocumentFormat.OpenXml.Wordprocessing.TableWidthUnitValues]::Auto
# }


$TextWrapping = [DocumentFormat.OpenXml.Wordprocessing.TextWrappingValues]::Auto
# $TextWrapping = [DocumentFormat.OpenXml.Wordprocessing.TextWrappingValues]::Auto
#$tableProperties.Append($TextWrapping);
#$tableProperties.Append($TableLook);
#$TableProperties.Append($TableStyle);
$TableProperties.TableStyle = New-OfficeWordTableStyle
# $TableStyle = [DocumentFormat.OpenXml.Wordprocessing.TableStyle]::new()
# $TableStyle.Val = "LightShading-Accent1"
# $TableStyle.Val = "TableGrid"


# $TableProperties.TableStyle = New-OfficeWordTableStyle
# $TableProperties.TableStyle = $TableStyle
# $TableProperties.TableLook = New-OfficeWordTableLook
#$TableProperties.TableBorders = New-OfficeWordTableBorder

# $TableProperties.TableBorders = New-OfficeWordTableBorder



$table.Append($TableProperties)
#$table.AppendChild($TableProperties)


if (-not $SkipHeader) {
Expand Down Expand Up @@ -67,6 +80,7 @@
$Table.Append($TableRow)
}

<#
# Table content
if ($DataTable[0] -is [System.Collections.IDictionary]) {
Expand All @@ -76,22 +90,21 @@
} else {
# PSCustomObject
foreach ($Data in $DataTable) {
$TableRow = [DocumentFormat.OpenXml.Wordprocessing.TableRow]::new()
#$TableRow = [DocumentFormat.OpenXml.Wordprocessing.TableRow]::new()
foreach ($Property in $Properties) {
$TableCell = [DocumentFormat.OpenXml.Wordprocessing.TableCell]::new()
$Paragraph = [DocumentFormat.OpenXml.Wordprocessing.Paragraph]::new()
if ($Data.$Property) {
$Text1 = New-OfficeWordText -Paragraph $Paragraph -Text $Data.$Property -ReturnObject
# $Text1 = New-OfficeWordText -Paragraph $Paragraph -Text $Data.$Property -ReturnObject
}
$TableCell.Append($Paragraph)
$TableRow.Append($TableCell)
}
$Table.Append($TableRow)
#$Table.Append($TableRow)
}
}
#>
$null = $Document.MainDocumentPart.Document.Body.Append($Table)


}

0 comments on commit ae018cd

Please sign in to comment.