?
Solved

powershell sort in excel sheet

Posted on 2014-09-10
2
Medium Priority
?
308 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_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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…
Suggested Courses

800 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