Reputation: 2769
I am using Powershell's (v2) ConvertTo-HTML
function to convert a SQL query to a table that I then include in an email.
On a basic level it works fine, but I now want to add some CSS to colour a field if that field is greater than 0.
My SQL is:
$SQL1 = "SELECT DATE, LS, TCO, FCO FROM test.table1
WHERE DATE = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
ORDER BY LS"
Example Data is:
'2015-09-29', 'aaa', 150, 10
'2015-09-29', 'bbb', 267, 0
My Powershell is:
$table1 = $result1 | `
ConvertTo-Html `
-property DATE, `
LSR, `
TCO, `
FCO `
-Fragment
$htmlbody = @"
<html>
<head><title>HTML TABLE</title></head>
<body>
<style> [CSS GOES HERE] </style>
. . .
$table1
</body>
</html>
"@
But I need to be able to add css to the last field on the table so if the field is > 0
I add a class to turn it red.
I'm assuming I need some kind of IF
statement somewhere
IF [field] > 0 THEN [ADD CLASS]
But can't see where to put it. Is this possible?
Upvotes: 0
Views: 944