none
CSS Formatting Table Row Height to HTML RRS feed

  • Question

  • Trying to export eventlog to html to display on IIS site and gotten the Style sheet from Microsoft Blog but need to limit height of the row in descriptions to like 3 lines.  Searched around but none of the formatting is working such as height:10px max-height:10px.

    $a = "<style>"
    $a = $a + "BODY{background-color:white}"
    $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
    $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}" #Table Header
    $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:white;max-height: 100px}" #Table Body
    $a = $a + "</style>"

    $comps = "server01","server02"

    Foreach ($comp in $comps) {
    Get-EventLog -LogName Application -After (Get-Date).AddDays(-1) -EntryType Error, Warning -ComputerName $comp |

    Select -property EventID, TimeGenerated, Source, machinename, EntryType, Message |

    ConvertTo-HTML -head $a -Body "<H2>Event Warnings & Errors</H2>" |

    Out-File $file -Append

    }


    • Edited by JT_CP Tuesday, October 27, 2015 10:54 PM clear title
    Tuesday, October 27, 2015 10:53 PM

Answers

All replies

  • $a = @'
    <style>
    	body{
    		background-color:white
    	}
    	table{
    		border-width:1px;
    		border-style:solid;
    		border-color: black;
    		border-collapse: collapse;
    	}
    	th{
    		border-width: 1px;
    		padding: 0px;
    		border-style: solid;
    		border-color: black;
    		background-color:thistle
    	} #Table Header
    	td{
    		border-width: 1px;
    		padding: 0px;
    		border-style: solid;
    		border-color: black;
    		background-color:white;
    		max-height: 100px
    	}
    </style>
    '@

    It is called a "Here" string.

    PowerShell comments cannot be used in a style block.  They will invalidate the whole style.

    This -  #Table Header - cannot be use

    Comments in style can be like C# - // or /* comment */

    This is how to write a style block in PowerShell



    \_(ツ)_/


    • Edited by jrv Tuesday, October 27, 2015 11:10 PM
    Tuesday, October 27, 2015 11:09 PM
  • This may help you but it is not what you are looking for:

    $head = @' <style type="text/css"> body{ background-color: antiquewhite; }   h2 {
    font-style: italic;
    text-align: center;
    }
    table { border-color: black; border-collapse: collapse; } td, th { border: 1px solid black; } th{ background-color:thistle } td{ background-color: pink; text-align: left; vertical-align: top; } </style> '@ $file='.\events.html' $computers = "w8test", "w8test" $computers | ForEach-Object{ Get-EventLog -LogName Application -After (Get-Date).AddDays(-1) -EntryType Error, Warning -ComputerName $_ } |   Select MachineName,EventID, TimeGenerated, Source, EntryType, Message |
    ConvertTo-HTML -head $head -Pre '<H2>Event Warnings & Errors</H2>' | Out-File $file . $file


    To adjust the height of a cell you have to use JavaScript.


    \_(ツ)_/



    • Edited by jrv Wednesday, October 28, 2015 12:05 AM
    Tuesday, October 27, 2015 11:55 PM
  • Sounds like limiting height is not something easily done.

    Anyway to trim the input Message say like truncate after 300 characters?

    Get-EventLog -LogName Application -After (Get-Date).AddDays(-1) -EntryType Error, Warning -ComputerName $comp |

    Select -property EventID, TimeGenerated, Source, machinename, EntryType, Message |

    ConvertTo-HTML -head $a -Body "<H2>Event Warnings & Errors</H2>" |

    Out-File $file -Append

    Wednesday, October 28, 2015 5:01 PM
  • Message.SubString(0,200)

    \_(ツ)_/

    • Marked as answer by JT_CP Friday, October 30, 2015 5:07 PM
    Wednesday, October 28, 2015 5:10 PM
  • Chopping off Message field.

    Foreach ($appitem in $app) 
        {
            $appitem.Message = ($appitem.Message).Substring(0,650)
            $appitem.MachineName = ($appitem.MachineName.Split('.'))[0]
            $apparray += $appitem
                }

    Friday, October 30, 2015 5:06 PM