mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added Export-StocksToExcel
This commit is contained in:
28
Export-StocksToExcel.ps1
Normal file
28
Export-StocksToExcel.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
function Export-StocksToExcel {
|
||||
param(
|
||||
[string]$symbols,
|
||||
[ValidateSet("Open", "High", "Low", "Close", "Volume")]
|
||||
$measure = "Open"
|
||||
)
|
||||
|
||||
$xl = "$env:TEMP\Stocks.xlsx"
|
||||
|
||||
Remove-Item $xl -ErrorAction SilentlyContinue
|
||||
|
||||
$r = Invoke-RestMethod "https://azfnstockdata-fn83fffd32.azurewebsites.net/api/GetQuoteChart?symbol=$($symbols)"
|
||||
|
||||
$chartColumn = $symbols.Split(',').count + 2
|
||||
$ptd = New-PivotTableDefinition `
|
||||
-SourceWorkSheet Sheet1 `
|
||||
-PivotTableName result `
|
||||
-PivotData @{$measure = 'sum'} `
|
||||
-PivotRows date `
|
||||
-PivotColumns symbol `
|
||||
-ChartType Line `
|
||||
-ChartTitle "Stock - $measure " `
|
||||
-IncludePivotChart -NoTotalsInPivot -ChartColumn $chartColumn -ChartRow 3 -Activate
|
||||
|
||||
$r | Sort-Object Date, symbol | Export-Excel $xl -PivotTableDefinition $ptd -AutoSize -AutoFilter -Show
|
||||
}
|
||||
|
||||
# Export-StocksToExcel -symbols 'ibm,aapl,msft' -measure High
|
||||
Reference in New Issue
Block a user