Solved

powershell sort in excel sheet

Posted on 2014-09-10
2
297 Views
Last Modified: 2014-09-12
hi folks,

I've an csv looks like as follows:
action  Version
new      c2010
new      XC
delete  c2010
delete  XC

I wish to change the script that both at action new(xc,c2010) starts up at Cell 2 until Cell 150 and Action delete should
start at 155. Thats not the complete script only the important code.

$map=@{}
$map['C2010'] = @{}
$map['XC'] = @{}
$map['C2010']['New']=2
$map['XC']['New']=2
$map['C2010']['Delete']=155
$map['XC']['Delete']=155

$objExcel = New-Object -ComObject Excel.Application
$objExcel.Visible = $false
$WorkBook = $objExcel.Workbooks.Open($strXlsFile)
$worksheet = $workbook.sheets.item("CAS")

Import-Csv -Path $strCsvFile -Delimiter ';' | % {
	$ver = $_.version
	if (!($ver -eq '')) {	
		$aktion = $_.aktion
		$rowNum = $map[$ver][$aktion]
		$col = 1
		$_.PSObject.Properties | %{
			$worksheet.cells.item($rowNum,$col++) = $_.value
		}
		$map[$ver][$aktion] = $rowNum+1
	}

Open in new window

0
Comment
Question by:Mandy_
  • 2
2 Comments
 
LVL 2

Accepted Solution

by:
Mandy_ earned 0 total points
ID: 40319637
$map=@{}
$map['C2010'] = @{}
$map['C2010']['New']=2
$map['C2010']['Delete']=155
0
 
LVL 2

Author Closing Comment

by:Mandy_
ID: 40319638
thats all i need
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now