Mit Powershell Excel fernsteuern

Was mit Word geht, geht auch mit Excel. Hier ein Beispiel, das ich im Netz (http://www.vistax64.com/powershell/173327-make-excel-chart-powershell.html) gefunden habe und etwas angepasst habe. Schade, dass die Sprachausgabe nur englisch ist:

# http://www.vistax64.com/powershell/173327-make-excel-chart-powershell.html
$excel = New-object -comobject Excel.Application
$excel.Visible = $true
$excel.DisplayAlerts = $false
$workbook = $excel.Workbooks.Add()
$sheet = $workbook.Worksheets.Item(1)
$sheet.Name = 'Hallo Welt'
 
foreach ($i in 1..25){
    $sheet.cells.item($i,1) = $i
    $sheet.cells.item($i,2) = $i*2
}
 
# Bar Chart
# Datenherkunft
$range = $sheet.range('a1:a25')
 
# Chart-Variable anlegen
$chart = $sheet.shapes.addChart().chart
# Typ zuweisen (Bar Chart)
$chart.chartType = 58
# Daten zuweisen
$chart.setSourceData($range)
1..48 | % {$chart.chartStyle = $_; $excel.speech.speak("Style $_"); sleep 2}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website