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?