Create excel file from command line

回眸只為那壹抹淺笑 提交于 2019-12-30 09:56:11

问题


is there any way to create a new excel file from command line? Thanks in advance.


回答1:


If the Excel files you need to create are always the same, you can create a template manually, then create new files at will with something like...

copy template.xlsx myNewSpreadsheet.xlsx

If you need to create files with content that varies, I suggest starting with the powershell solution proposed by David.




回答2:


You can do this using PowerShell:

PS> $excel = New-Object -ComObject "Excel.Application"
PS> $wb = $excel.Workbooks.Add()
PS> $ws = $wb.ActiveSheet
PS> $excel.Visible = $True

       < do some work >

PS> $wb.SaveAs("xltest.xlsx")
PS> $wb.Close()
PS> $excel.Quit()


来源:https://stackoverflow.com/questions/13635434/create-excel-file-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!