Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. $excel = New-Object -ComObject excel.application
  2.  
  3. #$excel.visible = $True
  4. $wb = $excel.Workbooks.Add()
  5. $ws = $wb.Worksheets.Item(1)
  6. $ws.Cells.Item(1,1) = 'Titre'
  7. $ws.Cells.Item(1,2) = 'Indice'
  8. $ws.Columns.Item('a').HorizontalAlignment = -4108
  9. $ws.Columns.Item('b').HorizontalAlignment = -4108
  10. $ws.columns.item('b').NumberFormat = "@"
  11.  
  12. $row = 2
  13. echo "Rechrche en cours ..."
  14.  
  15. ls -directory -r -path "scan*" | % {
  16.  
  17. $name = $_.name.Replace("__","_")
  18. $parts = $name.Split("_")
  19. if ( $parts.Count -gt 2 ) {
  20. #$namedoss = $parts[1],$parts[2] -join "_"
  21. #echo $namedoss >> lt.txt
  22. $ws.Cells.Item($row,1) = $parts[1]
  23. $ws.Cells.Item($row,2) = $parts[2]
  24. $row += 1
  25. }
  26.  
  27. }
  28.  
  29. $outputpath = join-path -Path $env:USERPROFILE -ChildPath "desktop\excelltest.xlsx"
  30.  
  31. echo "Enregistrement sur $outputpath ..."
  32. $wb.SaveAs($outputpath)
  33. $excel.Quit()
  34. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement