xls转xlsx - 单个文件.bat- # & cls & @cd /d "%~dp0" & powershell "Get-Content '%~0' | Out-String | Invoke-Expression " & exit /b
- $Excel = New-Object -ComObject Excel.Application
- $Excel.Visible = $false
- $Workbook = $Excel.Workbooks.Open("C:\Test\Excel\1.xls")
- $Workbook.CheckCompatibility = $false
- $Workbook.SaveAs("C:\Test\Excel\1.xlsx", 51)
- $Workbook.Close()
- $Excel.Quit()
复制代码 xls转xlsx - 多个文件.bat- # & cls & @cd /d "%~dp0" & powershell "Get-Content '%~0' | Out-String | Invoke-Expression " & exit /b
- $OldFolder = "C:\Test\From"
- $NewFolder = "C:\Test\To"
- $Excel = New-Object -ComObject Excel.Application
- $Excel.Visible = $false
- Get-ChildItem -Path $OldFolder\*.xls -File | ForEach-Object {
- $NewName = $NewFolder + "\" + $_.BaseName + ".xlsx"
- "[From] " + $_.FullName
- "[To] " + $NewName
- $Workbook = $Excel.Workbooks.Open($_.FullName)
- $Workbook.CheckCompatibility = $false
- $Workbook.SaveAs($NewName, 51)
- $Workbook.Close()
- }
- $Excel.Quit()
复制代码 xlsx转xls - 单个文件.bat- # & cls & @cd /d "%~dp0" & powershell "Get-Content '%~0' | Out-String | Invoke-Expression " & exit /b
- $Excel = New-Object -ComObject Excel.Application
- $Excel.Visible = $false
- $Workbook = $Excel.Workbooks.Open("C:\Test\Excel\1.xlsx")
- $Workbook.CheckCompatibility = $false
- $Workbook.SaveAs("C:\Test\Excel\2.xls", 56)
- $Workbook.Close()
- $Excel.Quit()
复制代码 xlsx转xls - 多个文件.bat- # & cls & @cd /d "%~dp0" & powershell "Get-Content '%~0' | Out-String | Invoke-Expression " & exit /b
- $OldFolder = "C:\Test\From"
- $NewFolder = "C:\Test\To"
- $Excel = New-Object -ComObject Excel.Application
- $Excel.Visible = $false
- Get-ChildItem -Path $OldFolder "*.xlsx" | ForEach-Object {
- $NewName = $NewFolder + "\" + $_.BaseName + ".xls"
- "[From] " + $_.FullName
- "[To] " + $NewName
- $Workbook = $Excel.Workbooks.Open($_.FullName)
- $Workbook.CheckCompatibility = $false
- $Workbook.SaveAs("$NewName", 56)
- $Workbook.Close()
- }
- $Excel.Quit()
复制代码
|