Monthly Archive

Categories

Open a CSV

PowerShell has great functionality for working with csv files.  They make an excellent way of saving information generated by PowerShell - for instance

Get-Process | Export-Csv data.csv -NoTypeInformation

Having created a csv file how can we read it?  It is possible to use Notepad but then the columns are not padded to the same width so the data can appear jumbled.  Ideally we would want to use an application that generated a grid view - like excel.

Excel is very easy to use for this

$xl = New-Object -comobject "excel.application"
$xl.WorkBooks.Open("C:\Scripts\Office\data.csv")
$xl.visible = $true

Create an object for the Excel application.  Open the csv file in a workbook and make it visible.

 

Share this post :

Technorati Tags: Powershell,Excel,CSV

Leave a Reply