DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

stnt
stnt

Posted on • Updated on

PowerShell misc.

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



#ใƒ—ใƒญใ‚ปใ‚นใ‚’็ต‚ไบ†ใ™ใ‚‹
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

16 Libraries You Should Know as a React Developer

Being a modern React developer is not about knowing just React itself. To stay competitive, it is highly recommended to explore the whole ecosystem. This article contains some of the most useful React component libraries to speed up your developer workflow.