PowerShell工作簿。以定界符分号打开 [英] PowerShell Workbooks.Open with delimiter semicolon

查看:91
本文介绍了PowerShell工作簿。以定界符分号打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft帮助我可以看到,可以在 Workbooks.Open 部分中定义自己的定界符。我遇到让它接受分号作为分隔符的问题。

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)

错误消息:

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

谢谢您的提示。

推荐答案

参数是固定位置,因此您不能仅将format参数放在文件名旁边。您需要执行以下操作:

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')

但是,正如@DavidBrabant所说,使用 Import-Csv可能会更好

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

这篇关于PowerShell工作簿。以定界符分号打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆