So I am writing code that processes data and writes it to an Excel file. Everything works good, but when I click on the SINGLE file in the folder that Powershell created, I get TWO Excel files to open up.
One is “Book1.xlsx” which contains my custom headers, tab names, and (sometimes) my data. The second is the correct output file “myfile.xlsx” which is exactly what I need.
EVERYTIME I click on “myfile.xlsx”, I get both to open up.
I don’t want to copy lots and lots of code here so I will paste some parts
The Beginning of the Writing-To-Excel Part
$excel = new-Object -comobject Excel.Application
$excel.visible = $false
$workBook = $excel.Workbooks.Add()
$sheet1 = $workBook.Sheets.Item(1)
$sheet2 = $workBook.Sheets.Item(2)
$sheet1.Name = “Tab1”
$sheet2.Name = “Tab2”
End of My Code
$workBook.SaveAs(“C:UsersaandersonDocumentsPowershellexport.xlsx”)
$excel.Quit()
submitted by /u/312pm
[link] [comments]
The post Powershell is creating two different Excel files of my same data? appeared first on How to Code .NET.