add chart with data source
hello,
i have powershell imports disk sizes servers , puts in excel.
no have chart display this. there way powershell don't have add hand. powershell follow:
$excel=new-object -comobject excel.application;$excel.visible=$true;
#setup workbooks
$sourceworkbook=$excel.workbooks.open($sourcefile);
$targetworkbook=$excel.workbooks.open($destfile);
#load worksheets
$sourceworkbook.worksheets.item(1).activate();
$targetworkbook.worksheets.item(1).activate();
#get source location
$sourcerange1=$sourceworkbook.worksheets.item(1).range("d2");
$sourcerange1.copy() | out-null
#look value ensure keeps searching empty cell
$foundemptycell = $false
#the first row check in range
$rownumber = 4
#declare variable
$range = ""
#loop through rows until find 1 without value
while (!$foundemptycell)
{
$range = "c{0}" -f $rownumber
$targetrange1=$targetworkbook.worksheets.item(1).range($range);
if ($targetrange1.value2 -eq $null)
{
$foundemptycell = $true
}
else
{
#write-host $targetrange1.value2
$rownumber++
}
}
#paste value in
$targetworkbook.activesheet.paste($targetrange1)
thanks !!!!!
hi,
looks can, i've got 0 experience excel com object myself.
Windows Server > Windows PowerShell
Comments
Post a Comment