【发布时间】:2021-06-25 19:38:15
【问题描述】:
我对 PowerShell 有点陌生。目前我正在尝试从 abd excel 文件中获取列并将它们存储到一个新的 CSV 文件中。
我设法使用以下方法从 excel 中获取了我需要的列:
$emails=$file.Worksheets['Form1'].UsedRange.Rows.Columns[4].Value2
$Response=$file.Worksheets['Form1'].UsedRange.Rows.Columns[8].Value2
其中$emails $Response 是System.array 包含
email1
...
email 20
和
Resp1 ...
Resp20
但是我没有得到这种格式:
Email , Response
----------------
email1, Resp1
Email2, Resp2
改为应用[pscustomobject]@{'emails' = $emails; 'Response' = $Response}
我是这样的:
emails Response
--- ---
{Email1, email2 ... email20} {Resp1..Resp20}
谁能帮我解决这个问题? 非常感谢!!
【问题讨论】:
-
使用这个
Join-Object script/Join-Object Module(另见:Is there a PowerShell equivalent ofpaste(i.e., horizontal file concatenation)?):$emails |Join $Response -Name Email, Response
标签: excel powershell csv