Saturday 15 August 2015

excel - powershell code for comparing two xls files -


I'am sticks coding with the requirement below.

I have two Excel (xls) files (old and new users list). In each file there are 4 fields "user id", "user name", "costcenter", "manager acceptance." Now, I need to check that each user ID is present in the user list in the old user list. If so, I have to copy / copy the values ​​of "cost center and acceptance manager" in the new user list with the values ​​of the same column from the old user list. Install If this situation fails, the new user will prevent the whole line light for "user-id" in the list, for which there is no match in the old user list and is not the last but at the least, the new user list I have to save around 2000+ userside

, I started coding to get the user list from the new user list in the array. From there, how do I get to modify the new user list like I have been told above? $ objExcel = new object -comobject excel.application $ UserWorkBook = $ ObjExcel.Workbooks.Open ("O: \ UserCert \ New_Users.xls") $ UserWorksheet = $ UserWorkBook.Worksheets.Item (1) $ OldUsers = @ () $ intRow = 2 #starting 2 since I exclude To do the heading is $ {$ OldUsers = $ UserWorksheet .Cells.Item ($ intRow, 1) .Value () $ intRow ++} While ($ UserWorksheet.Cells.Item ($ intRow, 1) .Value () - Ne $ tap)

For any help, much appreciated ...

If the user ID in each list of some types of regular, then it should be easy to open both workbooks at the same time, maintaining 2 signals (Row_for_old_userlist and Row_for_new_userlist) and old Compare the contents of the new User ID with one.

They are not in the shape of some order, then for each item in the new user, you have to scan the entire old list of inventory and then take your action to find them.

I am not sure that savings in CSV are a legitimate approach to your needs - you can not get data like this.

However - I think is actually asking how to determine the value of an Excel spreadsheet cell.

If so, there are some code that I use to insert a list of flaws in a spreadsheet ... and then set the column of the last cell for a different color, oddly, This "value 2" part ... ask me why it is "value 2" but this is non-negotiable. ($ X = 0; $ x -lt $ defects.count; $ x ++) {$ row ++ [string] $ ENGIssue = $ defect [$ x] $

 for  Sheet.Cells.Item ($ line, 1) .value2 = $ ENGIssue} $ range = $ sheet.range (("a {0}" -f $ line), ("b {0}" -f $ line) ) $ Range.select () | Out-null $ range.Interior.ColorIndex = 6    

No comments:

Post a Comment