get all excel processes stop when it's done
& { # Create a temporary child scope.
$excel = new-object -ComObject excel.application # create excel object
$workbook = $excel.Workbooks.Add() # add a workbook
$ws1 = $workbook.Worksheets.Item(1) # reference the 1st sheet
# You must *always* call .Quit(), otherwise the Excel process lingers
# for the entire OS users session.
$excel.Quit()
} # On exiting this block, $excel, $workbook, and $ws1
# go out of scope and release the COM objects when the
# garbage collector runs next.
# Run the garbage collector now.
# The Excel process should terminate shortly after.
ใผใผใผใผ
#CSV ใ่ชญใฟ็ดบใง Excel ใงๅบๅใใใ
#ๆขใซใใกใคใซใใใๅ ดๅใฏๅผทๅถ็ใซไธๆธใใใใ
#ๅ่๏ผXlFileFormat ๅๆๅ
#https://msdn.microsoft.com/ja-jp/library/microsoft.office.interop.excel.xlfileformat(v=office.11).aspx
$excel = New-Object -ComObject Excel.Application
$book = $excel.Workbooks.Open("c:\temp\test.csv")
#่ญฆๅใชใใซไธๆธใ
$excel.DisplayAlerts = $false
#Excel 2003ๅฝขๅผใฎ xls ใงไฟๅญใใๅ ดๅ
$book.SaveAs("c:\temp\test.xls", [Microsoft.Office.Interop.Excel.XlFileFormat]::xlWorkbookNormal)
#Excel 2007ไปฅๅพใฎๅฝขๅผใฎ xlsx ใงไฟๅญใใๅ ดๅ
$book.SaveAs("c:\temp\test.xlsx", [Microsoft.Office.Interop.Excel.XlFileFormat]::xlExcel5)
#HTML ๅฝขๅผใงไฟๅญใใๅ ดๅ
$book.SaveAs("c:\temp\test.html", [Microsoft.Office.Interop.Excel.XlFileFormat]::xlHtml)
$excel.Quit()
#ใใญใปในใ็ตไบใใ
Top comments (0)