Solved

powershell sort in excel sheet

Posted on 2014-09-10
2
296 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
Comment Utility
$map=@{}
$map['C2010'] = @{}
$map['C2010']['New']=2
$map['C2010']['Delete']=155
0
 
LVL 2

Author Closing Comment

by:Mandy_
Comment Utility
thats all i need
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article will help you understand what HashTables are and how to use them in PowerShell.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

12 Experts available now in Live!

Get 1:1 Help Now