Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

Update Excel Data with Password in PowerShell

I need open a excel file with password, update, save and close.

I try this code, but i havent sucessed.

Anyone Can help me?

#Set the file path (can be a network location)
$filePath = "C:Users12291DesktopExcelBase Vendas 2020_NOVA.xlsx"

#Create the Excel Object
$excelObj = New-Object -ComObject Excel.Application

#Make Excel visible. Set to $false if you want this done in the background
$excelObj.Visible = $true
$updatelinks = 3D



#Open the workbook
$workBook = $excelObj.Workbooks.Open($filePath, $updatelinks,$false, 0,5 , "vendas")

#Focus on the top row of the "Data" worksheet
#Note: This is only for visibility, it does not affect the data refresh
#$workSheet = $workBook.Sheets.Item("Data")
#$workSheet.Select()

#Refresh all data in this workbook
$workBook.RefreshAll()

#Save any changes done by the refresh
$workBook.Save()

#Uncomment this line if you want Excel to close on its own
#$excelObj.Quit()

question from:https://stackoverflow.com/questions/65909799/update-excel-data-with-password-in-powershell

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...