Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to append multiple sheets on a excel file(.xlsx format) in Powershell?

$
0
0

Currently I have a script in which I generate reports and save it in an .xlsx format. But my problem is when I try to generate a second report and onward, it overwrites the entire report instead of appending to it as a second sheet and onwards. Anyways Ill show you guys a very partial script.

$excel2 = New-Object -ComObject excel.application; $excel2.visible=$false; $serverInfoSheet= $excel2.Workbooks.Open("C:\Temp\Tasks[$i].csv"); # i is just a number starting from 1, I have the counter already in my full script $serverInfoSheet.Activesheet.Cells.EntireColumn.Autofit(); $ServerInfosheet.SaveAs("C:\Temp\report.xlsx",51) $excel2.Quit()

How can I modify so that the report accepts multiple sheets?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>