Hello ,
I am using a script which takes .csv file as input and create one Excel file in different worksheet.Script below:
$files = get-childitem 'D:\script\'
$datafiles = $files | where {$_.extension -eq ".csv"}
$Excel = New-Object -Com Excel.Application
$Excel.ScreenUpdating = $false
$Excel.DisplayAlerts = $false
$WorkBook = $Excel.Workbooks.Open('D:\script\'+$datafiles[0].name)
$mv = [System.Reflection.Missing]::Value
for ($index = 1; $index -lt $datafiles.Count; $index++)
{
$WorkSheet = $WorkBook.Sheets.Add($mv,$mv,$mv,'D:\script\'+$datafiles[$index].name)
$workSheet.Cells.EntireColumn.AutoFit()
}
$Excel.Visible = $True
$Excel.DisplayAlerts = $True
$Excel.ScreenUpdating = $True
Query : Script works perfectly fine , only probelm is I want the worksheet to be created in alphabetic order.The csv files that I have unde script directory are a.csv , b.csv,c.csv,d.csv.But I dont get the workshet created alphabetically.
Any help is much appreciated.
Regards
Deepak Anand
Deepak Anand