RamblingCookieMonster / PSExcel

A simple Excel PowerShell module

Home Page:http://ramblingcookiemonster.github.io/PSExcel-Intro/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copy Row to different worksheet

cesugden opened this issue · comments

I'm trying to copy a row to a different worksheet. I can't find an easy way of doing it. Is what I've written here the best way?

` $row = @(Get-CellValue -worksheet $Worksheet -Coordinates "A2:J2")

$DifferentWorksheet.SetValue($lastrow,1, $row.'#')

$DifferentWorksheet.SetValue($lastrow,2, $row.Action)

$DifferentWorksheet.SetValue($lastrow,3, $row.Project)

$DifferentWorksheet.SetValue($lastrow,4, $row.Context)

$DifferentWorksheet.SetValue($lastrow,5, $row.Area)

$DifferentWorksheet.SetValue($lastrow,6, $row.Time)

$DifferentWorksheet.SetValue($lastrow,7, $row.Due)

$DifferentWorksheet.SetValue($lastrow,8, $row.NA)

$DifferentWorksheet.SetValue($lastrow,9, $row.Created)

$DifferentWorksheet.SetValue($lastrow,10, $row.Finished)

$excel.save()`

Figured it out. Sorry didn't realise to look at EPPlus docs

$WorkSheet.Cells["A2:J2"].Copy($DifferentWorkSheet.Cells["A2:J2"])

Good find! Thanks for sharing! Yeah, PSExcel is somewhat limited in terms of working with existing data, the EPPlus library is always a good bet

Cheers!