Multiple csv files into a xlsx file but different sheets using powershell
问题 I have 20 csv files. Each are unrelated. How do I combine them together into one xlsx file with 20 sheets, each named after the csv files. $root = "C:\Users\abc\Desktop\testcsv" $CSVfiles = Get-ChildItem -Path $root -Filter *.csv $xlsx = "C:\Users\abc\Desktop\testxl.xlsx" #output location $delimiter = "," #delimiter #Create a excel $xl=New-Object -ComObject Excel.Application $xl.Visible=$true #add a workbook $wb=$xl.WorkBooks.add(1) ForEach ($csv in $CSVfiles){ #name the worksheet $ws=$wb