Powershell Excel Automation


hi all,

hope can help, have excel document need create new sheet there doesn't seem simple way of creating new sheet in populated excel document. there easy way of creating new sheet in document without overwriting current excel spreadsheet?

the code people use following:

$xl = new-object -comobject excel.application

$workbook = $xl.workbooks.add()
$sheet1 = $workbook.worksheets.item(1)

the code overwrites current content , replaces new workbook, how can add sheet?

if i'm not clear on i'm asking please ask.

thanks

dave

this works:

$workbook = $xl.workbooks.open("c:\temp\test.xls")

$workbook.worksheets.add([system.reflection.missing]::value) | out-null



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Group Policy Event ID 1058 Error Code 1326 (The user name or password is incorrect)

Suspicious event log Event ID: 4905

DCOM received error "2147746132" from...