Created
December 2, 2014 16:21
-
-
Save constructor-igor/51c37c82c97fd7d3d42f to your computer and use it in GitHub Desktop.
powershell: how to create and set data to excel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [array] $dataX = 0, 1, 2, 3, 4 | |
| [array] $dataY = 0.9, 0.5, 0.2, 0.9, 0.99 | |
| $excel = New-Object -ComObject Excel.Application | |
| $excel.Visible = $true | |
| $workbook = $excel.Workbooks.Add() | |
| $sheet = $workbook.ActiveSheet | |
| $counter = 0 | |
| $counter = 1 | |
| $dataX | ForEach-Object { | |
| $counter++ | |
| $sheet.cells.Item($counter, 1) = $_ | |
| } | |
| $counter = 1 | |
| $dataY | ForEach-Object { | |
| $counter++ | |
| $sheet.cells.Item($counter, 2) = $_ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment