Right-aligns numeric data in an HTML table for emailing, and optionally zebra-stripes &c.
Format-HtmlDataTable.ps1 [[-Caption] <String>] [[-OddRowBackground] <String>] [[-EvenRowBackground] <String>]
[-TableAttributes <String>] [-CaptionAttributes <String>] [-NumericFormat <String>] [-Html <String>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
Invoke-Sqlcmd "..." |ConvertFrom-DataRow.ps1 |ConvertTo-Html |Format-HtmlDataTable.ps1
Runs the query, parses each row into an HTML row, then fixes the alignment of numeric cells.
$rows |ConvertTo-Html -Fragment |Format-HtmlDataTable.ps1 'Products' '#F99' '#FFF'
Renders DataRows as an HTML table, right-aligns numeric cells, then adds a caption (“Products”), and alternates the rows between pale yellow and white.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The background CSS value for odd rows.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The background CSS value for even rows.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Any table attributes desired (cellpadding, cellspacing, style, &c.).
Type: String
Parameter Sets: (All)
Aliases: TableAtts
Required: False
Position: Named
Default value: Cellpadding="2" cellspacing="0" style="font:x-small 'Lucida Console',monospace"
Accept pipeline input: False
Accept wildcard characters: False
Type: String
Parameter Sets: (All)
Aliases: CaptionAtts, CapAtts
Required: False
Position: Named
Default value: Style="font:bold small serif;border:1px inset #DDD;padding:1ex 0;background:#FFF"
Accept pipeline input: False
Accept wildcard characters: False
Applies a standard .NET formatting pattern to numbers, such as N or ‘#,##0.000;(#,##0.000);zero’.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The HTML table data to be piped in.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Assumes only one <tr> element per string piped in, as produced by ConvertTo-Html.