$excel = New-Object Microsoft.Office.Interop.Excel.ApplicationClass
$table=$excel.Workbooks.open("C:\Users\admin\Desktop\test.xls")
$sheet=$table.Worksheets.Item(1)
#$excel.Visible=1
$copylist=$sheet.Pictures()
$excel.Application.DisplayAlerts = 0
foreach($copy in $copylist){
$name=$copy.name
#选中图片
$excel.ActiveSheet.Shapes.Range([Array]($name)).Select()
#重设图片为原始大小
$excel.Application.Selection.ShapeRange.ScaleWidth(1, [Microsoft.Office.Core.MsoTriState]::msoTrue , [Microsoft.Office.Core.MsoScaleFrom]::msoScaleFromTopLeft)
$excel.Application.Selection.Copy()
#新建一个chart
$Chart=$excel.ActiveSheet.ChartObjects().add(1000, 0, $excel.Application.Selection.Width, $excel.Application.Selection.Height).Chart
$Chart.Paste()
#导出成jpg文件
$null=$Chart.Export("C:\Users\admin\Desktop\test2\$name.jpg","JPG")
$excel.ActiveSheet.ChartObjects().delete()
}
$excel.Application.Quit()
$excel.quit()