PowerShell Color Codes and Formatting Notes for Excel

Now for something totally different!

For reference, a list of color codes and formatting options - essentially for producing nicely formatted and colored Microsoft Excel spreadsheets via PowerShell.

Some Formatting Options in PowerShell for Excell

$cells.item($row,$column) = ”Output”
$cells.item($row,$column)
.font.bold = $True
.font.Italic = $True
.font.size = 16
.font.ColorIndex = 2
.Interior.ColorIndex = 3
.HorizontalAlignment = -4108 # $xlCenter
.HorizontalAlignment = -4131 # $xlLeft
.HorizontalAlignment = -4152 # $xlRight
.EntireRow.+

The Top 16 Colors with Codes for working with Excel via in PowerShell

1 = black
2 = white
3 = red
4 = lime
5 = blue
6 = yellow
7 = fuchsia
8 = aqua
9 = maroon
10 = green
11 = navy
12 = olive
13 = purple
14 = teal
15 = silver
16 = gray

Image: The Colors
Credits: http://gallery.technet.microsoft.com/office/6c8f0604-ebe1-473a-b35c-31c49890abef and Kent Finkle with his List-ExcelColorValues.ps1 PowerShell script.

SEO: Why this post? It directly answers the question “what number is the color red in PowerShell for Microsoft Excel?”

Comments