I have used a bit of script i found to create a graph in excel but i cant figure how to end this in saving the file as xlsx/xls as nothing i try seems to work. I would also like to know how i can save the graph as an image from this script.. here is the script
$File="c:\datareporting\Temp\hpsim1.csv"
#Create excel COM object $Excel
=New-Object-comobject
Excel.Application
#Make Visible
$excel.Visible =
$True
$excel.DisplayAlerts =
$False
#Various Enumerations
$xlDirection=[Microsoft.Office.Interop.Excel.XLDirection]
$excelChart=[Microsoft.Office.Interop.Excel.XLChartType
]
$excelAxes=[Microsoft.Office.Interop.Excel.XlAxisType
]
$excelCategoryScale=[Microsoft.Office.Interop.Excel.XlCategoryType
]
$excelTickMark
=[Microsoft.Office.Interop.Excel.XlTickMark
]
Write-Verbose
"Attempt to resolve $($File)"
-Verbose
$File= (Convert-Path$File
)
#Add CSV File into Excel Workbook
$null=$excel.Workbooks.Open($File
)
$worksheet=$excel.
ActiveSheet
$Null=$worksheet.UsedRange.EntireColumn.
AutoFit()
#Assumes that date is always on A column
$range=$worksheet.Range("A2"
)
$selection=$worksheet.Range($range,$range.end($xlDirection::
xlDown))
$Start= @($selection)[0].
Text
$End= @($selection)[-1].
Text
$chart
=$worksheet.Shapes.AddChart().Chart
And here is the sample data i used in the csv...
daterun
| Audited
| HPSim
|
04/08/2015 00:00
| 67
| 36
|
05/08/2015 00:00
| 71
| 40
|
Thanks to anyone who can help