diff --git a/Examples/New-PSItem.ps1 b/Examples/New-PSItem.ps1 new file mode 100644 index 0000000..b186dcc --- /dev/null +++ b/Examples/New-PSItem.ps1 @@ -0,0 +1,23 @@ +function New-PSItem { + + $totalArgs = $args.Count + + if($args[-1] -is [array]) { + $script:PSItemHeader=$args[-1] + $totalArgs-=1 + } + + $h=[ordered]@{} + + for ($idx = 0; $idx -lt $totalArgs; $idx+=1) { + if($PSItemHeader) { + $key = $PSItemHeader[$idx] + } else { + $key = "P$($idx+1)" + } + + $h.$key=$args[$idx] + } + + [PSCustomObject]$h +} \ No newline at end of file diff --git a/Examples/SpreadsheetCells/ExcelFunctions.ps1 b/Examples/SpreadsheetCells/ExcelFunctions.ps1 new file mode 100644 index 0000000..4760e51 --- /dev/null +++ b/Examples/SpreadsheetCells/ExcelFunctions.ps1 @@ -0,0 +1,12 @@ +. ..\New-PSItem.ps1 + +rm *.xlsx + +$( + New-PSItem =2%/12 60 500000 "=pmt(rate,nper,pv)" (echo rate nper pv pmt) + New-PSItem =3%/12 60 500000 "=pmt(rate,nper,pv)" + New-PSItem =4%/12 60 500000 "=pmt(rate,nper,pv)" + New-PSItem =5%/12 60 500000 "=pmt(rate,nper,pv)" + New-PSItem =6%/12 60 500000 "=pmt(rate,nper,pv)" + New-PSItem =7%/12 60 500000 "=pmt(rate,nper,pv)" +) | Export-Excel functions.xlsx -AutoNameRange -AutoSize -Show \ No newline at end of file