Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

A fastest way to write values to Excel cells?

$
0
0

Howdy Spicy and Powershelling friends,

I'm (still ... gosh) working with PS and Excel to write down reports of folder analysis with robocopy.

It's all working, but now I want to speed up the process.

I've found a really good way to create the initial values (I mean, the first time the sheet is created and filled with robocopy values), using a .net array then throw it in the actual sheet :

Powershell
$count=$values.Countif($values.Count-eq$null){$count=1$rowtogo=2}else{$rowtogo=$values.Count+1}$arraynet=New-Object'object[,]'$count,3$i=0foreach($entryin$values){try{$arraynet[$i,0]=$entry.Root}catch{"!!!"}$arraynet[$i,1]=$entry.Directory$arraynet[$i,2]=$([string]$entry.size).replace(",",".")-as[double]$i++}$range=$sheetname.cells.range("A2:C$($rowtogo)")$range.value2=$arraynet

This...

Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>