我想将文本文件转换为Excel格式。我使用Technet中的以下脚本:
# Script name: ConvertTilde.ps1
# Created on: 2007-01-06
# Author: Kent Finkle
# Purpose: How Can I Convert a Tilde-Delimited File to Microsoft Excel Format?
$s = gc C:\Scripts\Test.txt
$s = $s -replace("~","`t")
$s | sc C:\Scripts\Test.txt
$xl = new-object -comobject excel.application
$xl.Visible = $true
$wb = $xl.Workbooks.Open("C:\Scripts\Test.txt")
$wb.SaveAs(“D:\Excel\Test.xlsx”)
脚本工作,excel打开并导入txt,但保存的文件只是重命名为xlsx的txt文件 - 如何让Excel更改文件格式?