PowerShell Workbooks.Open with delimiter semicolon

扶醉桌前 提交于 2019-12-11 19:00:08

问题


From the Microsoft help I can see that it's possible to define your own delimiter in the part Workbooks.Open. I'm having issues to have it accept semicolons as a delimiter.

This is part of a bigger script where my tried changes failed:

$tempcsv = $excel.Workbooks.Open("$input",6,";")
$tempcsv = $excel.Workbooks.Open("$input",6,4)

Error message:

Exception calling "Open" with "3" argument(s): "Open method of Workbooks class failed"

Thank you for your tips guys.


回答1:


The arguments are positional so you can't just put the format argument next to the filename. You'll need to do something like the below:

$excel.workbooks.open("$input",$null,$null,'4')

However, as @DavidBrabant says, you'd probably be better off using Import-Csv



来源:https://stackoverflow.com/questions/25179700/powershell-workbooks-open-with-delimiter-semicolon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!