Hello powershell gurus,
I am a newbie to powershell and is trying to create an excel chart from a csv file using powershell.
The powershell code is as follows
$excel = New-Object -comobject "Excel.Application"
$workbooks = $excel.Workbooks.Open("C:\PTest\cpu1.txt")
$ws = $workbooks.WorkSheets.Item(1)
$range = $ws.usedRange
#Now add our charts to the workbook
$workbooks.Charts.Add() | out-null
$workbooks.ActiveChart.chartType = [microsoft.office.interop.excel.xlChartType]::xlLine
$workbooks.ActiveChart.SetSourceData($range)
$workbooks.SaveAs("C:\PTest\test.xlsx")
$excel.Quit()
The csv file has two columns
timestamp,"Utilization"
1282744080,6.1730450000e+00
etc.
When I produce the graph, ideally I want the timestamp on the horizontal axis and Utilization on the vertical axis.What I am getting is both these columns on the vertical axis, drawn against the row counter on the horizontal axis.
Any help much appreciated.
Thanks,
S. |