Author Posts

July 14, 2014 at 2:20 pm

I am making a powershell report that generates a table presently the top part of the table is blue and font color is black , the body of the table is "whitesmoke"

 
$color = 'Blue'
$tableColor = "whitesmoke"

# HTML Style Definition
$REPORT = ""
$REPORT = ""
$REPORT = ""
$REPORT = $REPORT + "TABLE{border-width:2px;border-style: solid;border-color: #C0C0C0 ;border-collapse: collapse;width: 100%}"
$REPORT = $REPORT + "TH{border-width: 2px;padding: 0px;border-style: solid;border-color: #C0C0C0 ;text-align: left}"
$REPORT = $REPORT + "TD{border-width: 2px;padding: 0px;border-style: solid;border-color: #C0C0C0 ;text-align: left}"
$REPORT = $REPORT + "TD{border-width: 2px;padding: 0px;border-style: solid;border-color: #C0C0C0 ;text-align: left}"
$REPORT = $REPORT + "H1{font-family:Calibri;}"
$REPORT = $REPORT + "H2{font-family:Calibri;}"
$REPORT = $REPORT + "Body{font-family:Calibri;}"
$REPORT = $REPORT + ""

# Title
$REPORT = $REPORT + "MY SQL REPORT : $($filedate)"

#Reboot
$REPORT = $REPORT + "TH{background-color:$($color)}TR{background-color:$($tableColor)}"
$REPORT = $REPORT + ($QUERY | ConvertTo-HTML -Fragment )  + " "

$REPORT = $REPORT + ""


I would like the font to be White does any one know how to adjust this so the font is white ?

July 14, 2014 at 4:08 pm

see attached..

July 14, 2014 at 4:11 pm

I try to use an in document style sheet, but it all depends on your comfort with CSS, here is an example I use on the Inactive AD Computer Report I generate.

$HTMLhead = @"


    
        Inactive Computer Report
    
        body
        {
            background-color:#FAFAFA;
            font-family:Arial;
            font-size:12pt; 
        }
        td, th 
        { 
            border:1px solid black;
            border-collapse:collapse; 
        }
        th 
        { 
            color:white;
            background-color:black; 
        }
        table, tr, td, th 
        {
            padding: 2px; 
            margin: 0px 
        }
        tr:nth-child(odd) 
        {
            background-color: lightgray
        }
        table 
        {
            margin-left:10%;
            width:80%
        }
        img
        {
        float:left;
        margin: 0px 25px;
        }
        #footer
        {
            display:block;
            width:100%;
            text-align:center;
        }
        h2
        {
            text-align:center;
        }
    


"@

That being said, for a table all you should have to do is edit this line:

$REPORT = $REPORT + "TABLE{border-width:2px;border-style: solid;border-color: #C0C0C0 ;border-collapse: collapse;width: 100%}"

to be:

$REPORT = $REPORT + " TABLE style='border-width:2px;border-style: solid;border-color: #C0C0C0 ;border-collapse: collapse;width: 100%; color:#FFFFFF' "

edit: not sure if you are applying the CSS you list in any other way, so in my version I setup the table cell as straight HTML with inline CSS.
multi-edits: because I kept trying to use angle brackets.

July 14, 2014 at 4:29 pm

thanks guys. that worked perfectly