#图片文件路径
$FilePath = "D:\img"
#图片之间的距离
$distance = 20
#图片左边的距离
$leftSize = 50
#图片上面的距离
$hight = 0
#图片的高
$length = 500
#图片的宽
$width = 500
$excel = New-Object -ComObject Excel.Application -Property @{
Visible = $true
DisplayAlerts = $false
}
$wb = $excel.WorkBooks.Add()
$sheet = $wb.sheeteets.Item(‘sheeteet1’)
$PNGList = Get-ChildItem -path $FilePath -recurse *.png | % { $_.FullName}
foreach($png in $PNGList){
$sheet.sheetapes.AddPicture($png,1,0,$leftSize,$hight,$length,$width)
$hight = $hight + $distance + $width
}