Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell在Excel中读取一个选项卡并导出为CSV_Excel_Powershell_Csv - Fatal编程技术网

Powershell在Excel中读取一个选项卡并导出为CSV

Powershell在Excel中读取一个选项卡并导出为CSV,excel,powershell,csv,Excel,Powershell,Csv,我想读取excel文件中的隐藏选项卡,复制该选项卡并将其导出到csv 我执行了这个命令,但它只输出该选项卡的元数据 $file=Get ChildItem$sp | Where object{$\名称-match$patten}| sort LastWriteTime-Descending | select-first 1 $wb=$excel.Workbooks.open($file.Name) $wb.Sheets.Item(4)|导出Csv-路径“c:\Users\Path\test.Cs

我想读取excel文件中的隐藏选项卡,复制该选项卡并将其导出到csv

我执行了这个命令,但它只输出该选项卡的元数据

$file=Get ChildItem$sp | Where object{$\名称-match$patten}| sort LastWriteTime-Descending | select-first 1
$wb=$excel.Workbooks.open($file.Name)
$wb.Sheets.Item(4)|导出Csv-路径“c:\Users\Path\test.Csv”

如何获取该选项卡(索引4)中的实际内容并另存为
test.csv

我将首先尝试使电子表格可见

使用与此类似的代码:

ws.sheet_state='可见'


这是一个猜测

你很接近。这应该可以做到

$ws = $wb.Sheets.Item(4)
$ws.SaveAs("c:\Users\path\test.csv", 6)
确保路径存在。

查看可用路径