![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Alternate rows colors This is the beginning of my script $a = "<style>" $a = $a + "BODY{background-color:white;}" $a = $a + "TABLE{border-width: 3px;border-style: solid;border-color: white;border-collapse: collapse;}" $a = $a + "TH{border-width: 3px;padding: 2px;border-style: solid;border-color: white;background-color:yellow}" $a = $a + "TD{border-width: 3px;padding: 2px;border-style: solid;border-color: white;background-color:lightblue}" $a = $a + "</style>" get-eventlog -logname application | select Source, EntryType | group-object Source | where-object {$_.Group -match "Error"} | select Name, Count | sort Name | convertto-html -head $a –body "<H2>Application Errors</H2>" | Out-File f:\app.htm Invoke-Expression f:\app.htm I would like to alternate the row color for each data; that is one row is lightblue, the next white, then the next row is lightblue and the next one white and it goes on like that. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Alternate rows colors On Jun 10, 2:09 pm, Jason1008 <Jason1...@xxxxxx> wrote: Quote: > This is the beginning of my script > > $a = "<style>" > $a = $a + "BODY{background-color:white;}" > $a = $a + "TABLE{border-width: 3px;border-style: solid;border-color: > white;border-collapse: collapse;}" > $a = $a + "TH{border-width: 3px;padding: 2px;border-style: > solid;border-color: white;background-color:yellow}" > $a = $a + "TD{border-width: 3px;padding: 2px;border-style: > solid;border-color: white;background-color:lightblue}" > $a = $a + "</style>" > > get-eventlog -logname application | select Source, EntryType | group-object > Source | where-object {$_.Group -match "Error"} | select Name, Count | sort > Name | convertto-html -head $a –body "<H2>Application Errors</H2>" | Out-File > f:\app.htm > > Invoke-Expression f:\app.htm > > I would like to alternate the row color for each data; that is one row is > lightblue, the next white, then the next row is lightblue and the next one > white and it goes on like that. Replace the ConvertTo-Html section with this: Foreach-Object -Begin { $a "<H2>Application Errors</H2>" "<table>" "<tr><th>Name</th><th>Count</th></tr>" $row = 0 } -Process { $style = "style='background-color: white;'"; if ( $row % 2 -eq 0 ) { $style = "style='background-color: lightblue;'"; } "<tr><td {0}>{1}</td><td {0}>{2}</td></tr>" -f $style, $_.Name, $_.Count $row++ } -End { "</table>" } | Out-File f:\app.htm Jeff |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Alternate rows colors $head= @" <style> BODY{background-color:white;} TABLE{border-width: 3px;border-style: solid; border-color:white;border-collapse: collapse;} TH{border-width: 3px;padding: 2px;border-style: solid;border-color: white;background-color:yellow} </style> <script language="JavaScript"> window.onload=function(){ var TRs = document.getElementsByTagName("TR"); for (i=1; i <= TRs.length ; i++){ if (i % 2 == 1){ TRs[i].style.backgroundColor = "green"; } else { TRs[i].style.backgroundColor = "red"; } } } </script> "@ get-eventlog -logname application | select Source, EntryType | group-object Source | where {$_.Group -match "Error"} | select Name, Count | sort Name | convertto-html -head $head –body "<H2>Application Errors</H2>" | Out-File f:\app.htm Invoke-Item d:\scripts\temp\gps.html --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > This is the beginning of my script > > $a = "<style>" > $a = $a + "BODY{background-color:white;}" > $a = $a + "TABLE{border-width: 3px;border-style: solid;border-color: > white;border-collapse: collapse;}" > $a = $a + "TH{border-width: 3px;padding: 2px;border-style: > solid;border-color: white;background-color:yellow}" > $a = $a + "TD{border-width: 3px;padding: 2px;border-style: > solid;border-color: white;background-color:lightblue}" > $a = $a + "</style>" > get-eventlog -logname application | select Source, EntryType | > group-object Source | where-object {$_.Group -match "Error"} | select > Name, Count | sort Name | convertto-html -head $a –body > "<H2>Application Errors</H2>" | Out-File f:\app.htm > > Invoke-Expression f:\app.htm > > I would like to alternate the row color for each data; that is one row > is lightblue, the next white, then the next row is lightblue and the > next one white and it goes on like that. > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How do I filter rows in one csv file matching a value in another | PowerShell | |||
| add an empty line to txt file every two rows. | PowerShell | |||
| Windows Mail Stationery Stopped Working, Also Font colors and background colors... | Vista mail | |||
| Add-on or tweak for multiple tab rows in IE7... | Vista General | |||