Using Powershell to Delete Excel Rows

Hi everyone.  Again, I am having trouble working with Excel via Powershell.  I am slowly learning my way around but cannot correctly utilize any information I may find that helps me get the correct results.  So far I am working on a project
at work that is automating the testing of our build process.  I am "borrowing" an excel sheet that I will save to my local machine to save as CSV.  However, before saving to CSV I need to remove the empty rows.  Unfortunately, the cells are
not really blank but still contain links to the server I pulled the workbook from.
I'm not sure what is easiest to do, but the "blanks" are within this range: A49:F320  and this is the range I'd like to delete.  The code I am currently working with is:
$Excel = new-object -comobject excel.application
$Excel.Visible = $False
$Workbook = $Excel.Workbooks.Open($BuildXLS)
$Worksheet = $Workbook.Worksheets.Item(1)
$i = 1
    If ($Worksheet.Cells.Item($i, 1).Value() -eq "  ") {
        $Range = $Worksheet.Cells.Item($i, 1).EntireRow
        $a = $Range.Delete()
        $i -= 1
    $i += 1
 Incidentally, mjolinor helped with an earlier issue parsing through the CSV.  It was only after looking at the output that I discovered my real issue is working with the Excel.
$data = import-csv $csv | Where-Object {$_.juris -ne " "}
#format Juris-Version results
foreach ($line in $data)
  if ($line.juris -eq 'US'){$line.Version = $FedVerNum}
   else {$line.Version = $ContentVer}
       write-output $line.juris$line.version | Out-File -Append "C:\1_JurisVersion.txt"
The output from that help session looks like:
US
$FedVerNum
State
$ContentVer
State
$ContentVer
Is there a away I can get this to read as
US $FedVerNum
state $ContentVer
state $ContentVer
state $ContentVer
Many thanks for the help and expertise!

The Excel constants are "magic" numbers that can be found in Excel via the Object Browser in the Visual Basic Editor.
There are several that I use all the time, so I made a list of the ones I use most often:
Const ForReading = 1
Const xlAscending = 1
Const xlGuess = 0
Const xlTopToBottom = 1
Const xlSortNormal = 0
Const xlCount = -4112
Const xlArea = 1
Const xlBar = 2
Const xlColumn = 3
Const xlLine = 4
Const xlPie = 5
Const xlRadar = -4151
Const xlXYScatter = -4169
Const xlCombination = -4111
Const xl3DArea = -4098
Const xl3DBar = -4099
Const xl3DColumn = -4100
Const xl3DLine = -4101
Const xl3DPie = -4102
Const xl3DSurface = -4103
Const xlDoughnut = -4120
Const xlPasteValuesAndNumberFormats = 12
Const xlpasteFormats = -4122
Const xlpasteValues = -4163
Const xlValues = &HFFFFEFBD ' -4163
Const xlNone   = &HFFFFEFD2 ' -4142
Const xlSelect = 3
Const xlCellTypeLastCell = 11 
Or you can "Include" them like this:
[reflection.assembly]::loadWithPartialname("Microsoft.Office.Interop.Excel") |
Out-Null
$xlConstants = "microsoft.office.interop.excel.Constants" -as [type]
$ws.columns.item("F").HorizontalAlignment = $xlConstants::xlCenter
$ws.columns.item("K").HorizontalAlignment = $xlConstants::xlCenter
 If you know what constants you need.
You can read about this here:
http://technet.microsoft.com/en-us/magazine/2009.01.heyscriptingguy.aspx

Similar Messages

  • How to Use PowerShell to Delete FIM Users That Have a Null attribute name

    FIM Community Information Center Article
    Wiki Page:
    How to Use PowerShell to Delete FIM Users That Have a Null <attribute name>
    Go to the FIM Community Information Center
    Mike Crowley | MVP
    My Blog --
    Planet Technologies

    Have you run side-by-side metrics on this?
    I've run the Delete Object method and your script against similar data sets and yours appears to take a fair bit longer. I'd have to re-run in identical circumstances, a few times, to really say for sure, but my initial impression is that it will take hours
    longer.
    I guess the point is somewhat moot anyway, as for me the bit that generally takes longest is the actual query, rather than the deletions.
    Boy how I wish I could just enter something into the FIM Portal directly that would blast out a bunch of users matching a query. One day...
    FIMSpecialist.com | MCTS: FIM 2010 | Now Offering
    ECMA1->ECMA2 Upgrade Services

  • Using Powershell to delete all users from the Portal

    Summary
    This script will delete all users from the Portal except for Administrator and the Built-In Sync account.
    Based on Markus's "Delete a User" script.
    Useful when developing your system if you want to quickly clear out the data and start again.
    set-variable -name URI -value "http://localhost:5725/resourcemanagementservice' " -option constant
    function DeleteObject
    PARAM($objectType, $objectId)
    END
    $importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
    $importObject.ObjectType = $objectType
    $importObject.TargetObjectIdentifier = $objectId
    $importObject.SourceObjectIdentifier = $objectId
    $importObject.State = 2
    $importObject | Import-FIMConfig -uri $URI
    if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}
    $allobjects = export-fimconfig -uri $URI `
    –onlyBaseResources `
    -customconfig "/Person"
    $allobjects | Foreach-Object {
    $displayName = $_.ResourceManagementObject.ResourceManagementAttributes | `
    Where-Object {$_.AttributeName -eq "DisplayName"}
    if([string]::Compare($displayName.Value, "Administrator", $True) -eq 0)
    {write-host "Administrator NOT deleted"}
    elseif([string]::Compare($displayName.Value, "Built-in Synchronization Account", $True) -eq 0)
    {write-host "Built-in Synchronization Account NOT deleted"}
    else {
    $objectId = (($_.ResourceManagementObject.ObjectIdentifier).split(":"))[2]
    DeleteObject -objectType "Person" `
    -objectId $objectId
    write-host "`nObject deleted`n" $displayName.Value }
    Go to the FIM ScriptBox
    http://www.wapshere.com/missmiis

    The DeleteObject function opens and closes a connection for each object.  This approach is faster:
    http://social.technet.microsoft.com/wiki/contents/articles/23570.how-to-use-powershell-to-delete-fim-users-that-have-a-null-attribute-name.aspx
    Mike Crowley | MVP
    My Blog --
    Planet Technologies

  • Re:Adding a row in a matrix using Lost_Focus event & deleting a row

    Dear All,
    Iam facing a problem in adding a row in a matrix using last focus event.its like if i keep the cusor in the last coloumn in a matrix n if i press tab it should add a row .the row is getting added the problem here is the cursor is gng to first row but it should come to the second row.
    the second problem is while deleting a row the row is getting deleted but the row count is showing the deleted row no.
    pls suggest a solution for these problems.
    Thanks & Regards
    Anand

    Hi,
    If pVal.BeforeAction = False Then
                Select Case pVal.EventType
                    Case SAPbouiCOM.BoEventTypes.et_KEY_DOWN
                        If pVal.ItemUID = "matlab" And pVal.ColUID = "mtimeout" And pVal.CharPressed = 9 Then
                            oMatrix = oForm.Items.Item("matlab").Specific
                            Dim rc As Integer = oMatrix.VisualRowCount
                            If rc = pVal.Row Then
                                addrow()    'funtion for adding row
                                oMatrix.Columns.Item("labc").Cells.Item(oMatrix.RowCount).Click()
                                'SBO_Application.MessageBox(oMatrix.RowCount)
                            End If
                        End If
    This is the function i hav used
    Private Sub addrow()
            Try
                If (oForm.UniqueID = "updt") Then
                    oForm = SBO_Application.Forms.ActiveForm
                    oForm = SBO_Application.Forms.Item("updt")
                    omatrix = oForm.Items.Item("matlab").Specific
                    omatrix.AddRow(1, omatrix.VisualRowCount)
                    Dim rc As Integer = omatrix.VisualRowCount
                    'SBO_Application.MessageBox(rc)
                    otext1 = omatrix.Columns.Item("mdatein").Cells.Item(rc).Specific
                    otext1.String = "s" 'RecSet.Fields.Item("date1").Value
                    otext1 = omatrix.Columns.Item("mdateout").Cells.Item(rc).Specific
                    otext1.String = "s" 'RecSet.Fields.Item("date1").Value
                    End If
            Catch ex As Exception
                SBO_Application.MessageBox(ex.Message)
            End Try
        End Sub
    this is the code which m using
    Regards,
    Anand

  • Use Preparedstatement to delete several rows from database

    Hello everyone,
    I am trying to delete multiple rows from database at one time using Preparedstatement.
    It works well when I tried in SQL directly,the sql query is as follows:
    delete from planners_offices where planner ='somename' and office in ( 'officeone', 'officetwo', 'officethree')
    I want to delete those 3 rows at one time.
    But when I am using preparedstatement to implement this function, it does not work. It did not throw any exception, but just does not work for me, the updated rows value always returns "0".
    Here is my simplified code:
    PreparedStatement ps = null;
    sqlStr = " delete from PLANNERS_OFFICES where planner = ? and office in (?) "
    Connection con = this.getConnection(dbname);
    try
    //set the sql statement into the preparedstatement
    ps = con.prepareStatement(sqlStr);
    ps.setString(1,"somename");
    ps.setString(2,"'officeone','officetwo','officethree'");
    int rowsUpdated =ps.executeUpdate();
    System.out.println(rowsUpdated);
    //catch exception
    catch (SQLException e)
    System.out.println("SQL Error: " + sqlStr);
    e.printStackTrace();
    catch (Exception e) {
    e.printStackTrace();
    } finally {
    this.releaseConnection(dbname, con);
    try{
    ps.close();
    }catch (SQLException e){
    e.printStackTrace();
    rowsUpdated always give me "0".
    I tried only delete one record at one time, "ps.setString(2, "officeone");", it works fine.
    I am guessing the second value I want to bind to the preparedstatement is not right, I tried several formats of that string, it does not work either.
    Can anyone give me a clue?
    Thanks in advance !
    Rachel

    the setString function in a preparedStatement doesn't just do a replace with the question mark. It is doing some internal mumbojumbo(technical term) to assign your variable to the ?.
    If you are looking to do your statement, then you will need to put in the correct of # of question marks as you need for the in clause.
    delete from PLANNERS_OFFICES WHERE PLANNER = ? and office in (?,?,?)
    If you need to allow for one or more parameters in your in clause, then you will need to build your SQL dynamically before creating your prepared statement.
    ArrayList listOfOfficesToDelete ;
    StringBuffer buffer = new StringBuffer("DELETE FROM PLANNERS_OFFICES WHERE PLANNER = ? AND OFFICE IN (");
    for(int i = 0; i < listOfOfficesToDelete.size(); i++ )
       if( i != 0 )
           buffer.append(",");
       buffer.append("?");
    buffer.append(")");
    cursor = conn.prepareStatement( buffer.toString() );
    cursor.setString(1, plannerObj);
    for(int i = 0; i < listOfOfficesToDelete().size(); i++ )
        cursor.setString(i+1, listOfOfficesToDelete.get(i) );
    cursor.executeUpdate() ;

  • Using PowerShell to delete user's permissions?

    Hello Forum,
    I am an accountant with zero backgroud in IT. I happen to be responsible on managing our small SharePoint 2010 environment (10 Web Applications, 20 Site Collections in each Web Application, and 300 Users), and even though it been a quite difficult task, I must
    admit that I am kinda enjoying it because I get a chance to learn new things.
    Whenever I encounter an issue, I google it up and most of the time I find answers on the Internet. Nevertheless, This time I think I am having a tough problem, that's why I have decided to register and post my question for the first time ever. 
    Well, I have a few users who have left our company, and they have permissions all over the place, some of these users have Full Control and Contribute permissions on different Site Collections, SubSites, Lists, and libraries across the Web Applications that
    we have.
    Unfortunately, We do not have a proper governance process in place, and yes things are messy in our SharePoint environment, I have noticed that some of these users were granted permissions on Lists and Libs directly without using any User Groups.
    Now, It is my responsability to clean up the environment. I have spent most of my weekend guessing and cleaning up manually our SharePoint environment, by jumping from Site to another and checking through the UI and removing the user from there, But this repeated
    manual work is killing my soul I swear.
    I read a bout PowerShell and I managed to test simple commands and I hope it is the way to go. I have been using this small script:
    $web = Get-SPWeb http://MySharePointSite
    $user = get-spuser -Identity Domain\UserAccount -Web $web.url
    $list = $web.Lists["Docs/Pics Library"]
    $list.RoleAssignments.Remove( $user)
    But again, Even though it is a bit faster than working with UI, I feel it not efficient enough because have to run it against every List, Docs Lib, Pics Lib...etcs
    So guys, Is there a way in PowerShell that allows me to give the user account and the Web Application URL as parameters, and the script runs and loops through the entire Web Application with all its Site Collections and SubSites, Lists, Libs and remove that
    user from there completely regardless if that user was added diretly or in a group?
    Can PowerShell automate such a process or am I dreaming?

    Yes it can.
    However before we get there, we should note something: If you're using Active Directory (AD) for your users, and you almost certainly are, as long as the leaver's account is marked as 'Disabled' in there then security wise you're fine. The rest is just to
    keep things clean.
    If you search a bit longer you'll probably find a more complete script but to extend yours a bit we can do a few things. What we want to do is introduce 'loops'. I'm assuming you know nothing about programing but a loop is a process where the code does a
    certain activity for a set number of times or until it reaches a point to finish.
    What we'll do is use three 'get things' commands to get all the sites, all the webs in a site and then all the lists in a web to get us a list of things to run our loop on, then run your remove code.
    #This gets all the site collections you have permission to see
    $sites = Get-SPSite -Limit All
    #This loops through each site collection and calls it 'siteCollection'
    foreach ($siteCollection in $sites)
    #This gets all the webs in the site collection
    $webs = $siteCollection.AllWebs
    #This loops through all the webs
    foreach ($website in $webs)
    $user = get-spuser -Identity Domain\UserAccount -Web $website.url
    #This gets all the lists in the library
    $lists = $web.Lists
    foreach ($list in $lists)
    $list.RoleAssignments.Remove( $user)
    Now this isn't great code, there's lots of ways it may not work perfectly but it shouldn't break anything. One thing you should remember is to close the PowerShell session once you've run it as this will suffer from memory leaks (where it keeps eating up
    RAM until you close the application).
    Another thing, have you discovered PowerShell ISE yet? It's vital if you want to do semi complicated PowerShell.
    Welcome to the wonderful world of SharePoint and PowerShell. If you want let me know and i can point you to some nice gentle 'how to' resources.
    And finally, this isn't the solution to your entire problem but it will do a decent chunk of it for you and could serve as a starting point to doing the entire lot...

  • Using powershell to delete a View

    Something happened to a View on our test server. Under Review Activities, the Activities Assigned to Me is broken. Don't know what I did. Probably stared at it too long and it broke. Never worked with a product so fragile. Anyway, when I right click the
    View, the only option is Refresh. The View works, I just can't edit or delete it.
    I just want to get rid of it. I have already replaced it with another View. Outside of the console commands, how do you remove a View from existence?

    It's in a Management Pack called "Service Manager Activity Management Configuration Library". There are views that come OOTB that are are in unsealed MP's. I think if you look this MP up in the console you will find that it's unsealed in your SCSM
    installation as well? Is it possible that someone exported this MP, made changes to it and reimported it? You can actually change a lot of console behavoir via the Management Packs.
    A possible solution for you might be to reimport an original version of this management pack. Just export your current version first and keep as a backup, in case someone stored some important configuration in there (which they should not do btw).

  • Using PowerShell to delete an ExpectedRuleEntry

    Summary
    The script code below deletes an ExpectedRuleEntry object from your environment.
    To run this script, you need to configure a Management Policy Rule that grants you permission to perform this operation:
    Management Policy Rule Configuration
    Name
    Administration: Administrators can delete Expected Rule Entries
    Type
    Request
    Grants Permissions
    True
    Disabled
    False
    Requestors and Operators
    Requestor
    Administrators
    Operation
    Delete
    Target Resources
    Before Request
    All expected rule resources
    After Request
    (Attribute)
    Resources Attributes
    All Attributes
    set-variable -name URI -value "http://localhost:5725/resourcemanagementservice" -option constant
    If(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}
    if($args.count -ne 1) {throw "Missing GUID parameter"}
    $objectGUID = $args[0]
    $exportObject = export-fimconfig -uri $URI `
    –onlyBaseResources `
    -customconfig "/ExpectedRuleEntry[ObjectID='$objectGUID']" `
    -ErrorVariable Err `
    -ErrorAction SilentlyContinue
    If($Err){Throw $Err}
    If($exportObject -eq $null) {throw "ERE not found"}
    $ImportObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
    $ImportObject.ObjectType = "ExpectedRuleEntry"
    $ImportObject.TargetObjectIdentifier = (($exportObject.ResourceManagementObject.ObjectIdentifier).split(":"))[2]
    $ImportObject.SourceObjectIdentifier = (($exportObject.ResourceManagementObject.ObjectIdentifier).split(":"))[2]
    $ImportObject.State = 2
    $ImportObject | Import-FIMConfig -uri $URI -ErrorVariable Err -ErrorAction SilentlyContinue
    If($Err){Throw $Err}
    Write-Host "`nCommand completed successfully`n"
    trap
    Write-Host "`nError: $($_.Exception.Message)`n" -foregroundcolor white -backgroundcolor darkred
    Exit 1
    Go to the FIM ScriptBox
    Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation

    I am getting error:-
    Missing GUID parameterIs there any problem with script? Kindly help

  • Deleting A Row From Datagrid

    Hai
        I have pasted the mxml below, because i am unable to attach the mxml, pl copy this below file into flex and run the application.
      1. Run the application.
      2. Enter values in the textbox and click add, values will be added to the datagrid.
      3. now click AND or OR and then change the values in the second and thrid combobox and again click add.
      4.Like wise change the combobox values and add five rows to the datagrid.
    5.now if u delete the last row u can see the curent last row in the combobox, so that the AND or Or can be added to it
    6. now if u delete a row in between, the deleted row's value oly maintains in the combobox,so i am unable to add AND or Or to the grid
      7.I need the last row data in the datagrid to be in the second and third combobox, which ever row is deleted.
    Can anyone help me....
    Thanks in advance.
    This is the mxml for sample
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
    <![CDATA[
      // ActionScript file
    import mx.rpc.events.FaultEvent;
    import mx.controls.Alert;
            import mx.managers.CursorManager;
    import mx.collections.ArrayCollection;
    [Bindable]
    public var adhoc:ArrayCollection = new ArrayCollection();
    [Bindable]
    public var serverString = "" ; 
          private function initImage(event:MouseEvent):void {
                  if(adhoc.length > 0){
                CursorManager.setBusyCursor();
              private function onChange():void{
          if(comboBox.selectedIndex == 0){
        }else{
              private function onChange1():void{
              if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
                datepick.visible = true
                txt.visible = false
              }else{
              txt.visible = true
                datepick.visible = false
        private function add():void{
        var str:String = txt.text;
        if(str.length == 0 && txt.visible == true){
            Alert.show("Value Can Not Be Empty");
            return;
          if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
              if(txt.visible == true){
                  var temp:Object = new Object();
        temp.fname = combo2.selectedItem;
        temp.opera = combo1.selectedItem;
        temp.val = "'"+txt.text+"'";
            adhoc.addItem(temp);
              txt.text = "";
          var str1:String = datepick.text;
          if(comboBox.selectedIndex == 1){
            if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
            if(str1.length == 0 && datepick.visible == true){
            Alert.show("Date Cannot Be Empty");
            }else{
            var temp:Object = new Object();
        temp.fname = combo2.selectedItem;
        temp.opera = combo1.selectedItem;
        temp.val = datepick.text;
              adhoc.addItem(temp);
              datepick.text = "";                   
        addbutton.enabled = false;
        addopenbracket.enabled = false;
        combo2.enabled = false;
        combo1.enabled = false;
        private function querydelete():void{
            if (AdHoc.selectedIndex > 0) {
                if(AdHoc.selectedIndex == (adhoc.length-1)){
              adhoc[AdHoc.selectedIndex-1].cond = "";
              addopenbracket.enabled = false;
              addclosebracket.enabled = false;
              addbutton.enabled = false;
              combo2.enabled = false;
              combo1.enabled = false;
              combo2.selectedItem = adhoc[adhoc.length-2].fname
              combo1.selectedItem = adhoc[adhoc.length-2].opera
                adhoc.removeItemAt(AdHoc.selectedIndex);
          //  adhocdetailgridcompilance.dataProvider = null ;
        //    adhocdetailgrid.dataProvider = null ;
            }else if (adhoc.length == 1) {
                adhoc.removeItemAt(AdHoc.selectedIndex);
          //  adhocdetailgridcompilance.dataProvider = null ;
        //    adhocdetailgrid.dataProvider = null ;
                addopenbracket.enabled = true;
              addclosebracket.enabled = true;
              addbutton.enabled = true;
              combo2.enabled = true;
              combo1.enabled = true;
            }else{
                Alert.show("Select The Rows To Delete");
          private function andSubmit():void{
            for each(var obj:Object in adhoc){
                if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
                  if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = and.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + "'"+txt.text+"'");             
              }else if(obj.fname == addclosebracket.label){
                if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = and.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + "'"+txt.text+"'");             
              if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
                if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
            if(datepick.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = and.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + datepick.text);             
                }else if(obj.fname == addclosebracket.label){
                if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = and.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + datepick.text);             
          addbutton.enabled = true;
          addopenbracket.enabled = true;
          combo2.enabled = true;
          combo1.enabled = true;
        private function orSubmit():void{
          for each(var obj:Object in adhoc){
                if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
                  if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = or.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
              }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + "'"+txt.text+"'");             
              }else if(obj.fname == addclosebracket.label){
                if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = or.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + "'"+txt.text+"'");             
              if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
                if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
            if(datepick.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = or.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
          }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + datepick.text);             
                }else if(obj.fname == addclosebracket.label){
                if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
                if(txt.visible == true){
                  trace("2 equals");
                  var temp:Object = new Object();
                  obj.cond = or.label
                  adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
                }else{
                  trace(obj.fname + ":" + combo2.selectedItem);
                  trace(obj.opera + ":" + combo1.selectedItem);
                  trace(obj.val + ":" + datepick.text);             
          addbutton.enabled = true;
          addopenbracket.enabled = true;
          combo2.enabled = true;
          combo1.enabled = true;
          public function addOpenBracket():void{
                var temp:Object = new Object();
              temp.fname = addopenbracket.label
          adhoc.addItem(temp);
          addopenbracket.enabled = false
          addclosebracket.enabled = true
                if(adhoc.length > 1 && addopenbracket.enabled == false){
                    addbutton.enabled = true
        public function addCloseBracket():void{
              var temp:Object = new Object();
              if(adhoc.length > 1){
            temp.fname = addclosebracket.label
            adhoc.addItem(temp);
            addopenbracket.enabled = true
            addclosebracket.enabled = false
          if(adhoc.length > 1 && addclosebracket.enabled == false){
                    addbutton.enabled = true
        private function dateChange(date:Date):void{
            if (date == null){
              }else{
                    txt.text = date.getDate() + '/' + (date.getMonth()+1).toString() + '/' +
                              date.getFullYear().toString() ;
        public function saveadhoc(event:Event):void {
                var AdhocRows:String = "";
        var i:int ;
              var selectedType = comboBox.selectedItem;
              if(adhoc.length == 0){
              Alert.show("Enter The Query");
              }else{
        for(i = 0; i < adhoc.length;i++) {
          if(adhoc[i].fname != null){
          AdhocRows = AdhocRows +adhoc[i].fname+" ";
          if(adhoc[i].opera != null){
          AdhocRows = AdhocRows + adhoc[i].opera+" ";
          if(adhoc[i].val != null){
          AdhocRows = AdhocRows + adhoc[i].val+" ";
          if(adhoc[i].cond != null){
          AdhocRows = AdhocRows + adhoc[i].cond+" ";
            var parameters:Object = {adhocquery:AdhocRows,FlexActionType:"ADHOCQUERYSUBMIT",adhocType:selectedType};
              //  adhocClick.send(parameters);
            private function retrieve():void{         
                datepick.visible = false
              txt.visible = true
    ]]>
    </mx:Script>
            <mx:Array id="comp">
                <mx:String>TYPE</mx:String>
            <mx:String>AUDITRESULT</mx:String>
            <mx:String>CATEGORY</mx:String>
            <mx:String>CHILDRULE</mx:String>
            <mx:String>PARENTRULE</mx:String>
            <mx:String>AUDITGROUP</mx:String>
            <mx:String>LOCATION</mx:String>
            <mx:String>VENDOR</mx:String>
            <mx:String>DEVICECATEGORY</mx:String>
        </mx:Array>
        <mx:Array id="inven">
      <mx:String>VENDOR</mx:String>
      <mx:String>DEVICETYPE</mx:String>
      <mx:String>SERIES</mx:String>
      <mx:String>MODEL</mx:String>
      <mx:String>SUP/CPU</mx:String>
      <mx:String>CODEVERSION</mx:String>
      <mx:String>IMAGENAME</mx:String>
      <mx:String>DATEDEPLOYED</mx:String>
      <mx:String>LOCATIONNAME</mx:String>
      <mx:String>ADDRESS1</mx:String>
      <mx:String>ADDRESS2</mx:String>
      <mx:String>CITY</mx:String>
      <mx:String>STATE</mx:String>
      <mx:String>COUNTRY</mx:String>
      <mx:String>FLOOR</mx:String>   
      <mx:String>CABINET</mx:String>
      <mx:String>CATEGORYNAME</mx:String>
      <mx:String>DEPARTMENT</mx:String>
      <mx:String>CONTACTNAME</mx:String>
      <mx:String>CONTACTNUMBER</mx:String>
      <mx:String>VERSION</mx:String>
      <mx:String>FILENAME</mx:String>
      <mx:String>DATEUPLOADED</mx:String>
    </mx:Array>
    <mx:Accordion x="13" y="55" width="230" height="492">
    <mx:Form label="AdHoc Query Analyzer"  width="100%"  creationComplete="retrieve()" height="100%" color="#F2F8F9" backgroundColor="#020202">
      <mx:Canvas label="Query" width="204" height="440" backgroundColor="#020202">
      <mx:ComboBox x="66" y="287" width="134"  id="comboBox" dataProvider="[COMPLIANCE , INVENTORY]" change="onChange()" color="#050505">
      </mx:ComboBox>
      <mx:ComboBox x="5" y="344" width="109.25" id="combo1" dataProvider="[=,!=,>,>=,&lt;,&lt;=,LIKE]" color="#010101"></mx:ComboBox>
      <mx:TextInput x="119.25" y="344" width="77.75" id="txt" color="#050505"/>
        <mx:Button x="3" y="401" label="Add" width="59" click="add()" id="addbutton" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="66" y="401" label="Delete" width="63.25" click="querydelete()" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="2" y="373" label="("  id="addopenbracket" click="addOpenBracket()"  width="45" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="51" y="373" label=")" id="addclosebracket" click="addCloseBracket()"  width="45" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="134.25" y="401" label="Submit" click="saveadhoc(event);initImage(event)" color="#FFFEFE" fillAlphas="[1.0, 0.69, 0.75, 0.65]" fillColors="[#77B97A, #77B97A, #EEEEEE, #EEEEEE]" borderColor="#77B97A" themeColor="#009DFF"/>
      <mx:ComboBox x="66" y="317" width="134" id="combo2" change="onChange1()" dataProvider="{comp}" color="#010101">
      </mx:ComboBox>
      <mx:DateField x="122.25" y="344" width="74.75" initialize="dateChange((event.target).selectedDate)" id="datepick" color="#050505"/>
      <mx:DataGrid x="1" y="1" width="203" height="282" id="AdHoc" dataProvider="{adhoc}" allowMultipleSelection="true" color="#020202">
      <mx:columns>
        <mx:DataGridColumn headerText="Name" dataField="fname" id="fnam"/>
        <mx:DataGridColumn headerText="Operator" dataField="opera" id="ope"/>
        <mx:DataGridColumn headerText="Value" dataField="val" id="valu"/>
        <mx:DataGridColumn headerText="Condition" dataField="cond" id="condt"/>
      </mx:columns>
      </mx:DataGrid>
      <mx:Button x="99" y="373" label="AND" width="52" click="andSubmit()" id="and" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Button x="154" y="373" label="OR" width="49" click="orSubmit()" id="or" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>
      <mx:Label x="7" y="291" text="TYPE" width="59" fontWeight="bold"/>
      <mx:Label x="5" y="319" text="DISPLAY" width="59" fontWeight="bold"/>
        </mx:Canvas>
      </mx:Form>
    </mx:Accordion>
    </mx:Application>

    Ok... but I am a little confused (sorry to be a nuisance ),
    my delete function within my webService requires an ID to be
    passed from the Flex application, thus when a row is selected, the
    ID of the selected row is taken, so when the Delete button is
    pressed it sends this ID to the webService where it is taken and
    used - and therefore deleting the row etc.....
    Do you mean to define the result handler for the deleteOPG
    operation in the main webService tag, i.e. :
    <mx:WebService id="wsData" wsdl=http://...?wsdl>
    <mx:operation name="getRes" result="handleWSR(event)"/>
    <mx:operation name="deleteOPG"
    result="handleWSR_deleteOPG(event)"/>
    </mx:WebService>
    and then call it in my delete function, passing the ID from
    my delete function to my new result handler function ??? :
    Thanks,
    Jon.

  • How to delete a row of table in Word using powershell.

    I want to search for a word which is present in Table. If that word is present than I want to delete that row from table.
    Can anybody help me with that. The script I am using is:
    $objWord = New-Object -ComObject word.application
    $objWord.Visible = $True
    $objDoc = $objWord.Documents.Open("C:\temp\Recipe.docx")
    $FindText = "DP1"
    $objSelection.Find.Execute($FindText)
    $objWord.Table.Cells.EntireRow.Delete()
    $objDoc.SaveAs("C:\Temp\P.docx")
    $Doc.Close()

    Maybe try this:
    $objWord = New-Object -ComObject word.application
    $objWord.Visible = $True
    $objWord.Documents.Open("C:\temp\Recipe.docx")
    $FindText = "DP1"
    $objWord.Selection.Find.Execute($FindText) | Out-Null
    $objWord.Selection.SelectRow()
    $objWord.Selection.Cells.Delete()
    $objWord.Documents.SaveAs("C:\Temp\P.docx")
    $objWord.Close()
    $objWord.Quit()
    [System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$objWord) | Out-Null
    This definitely assumes the text you're trying to find only exists in a table, per your specified requirements.  If it exists anywhere else, or in multiple tables, the code above is inadequate.
    I hope this post has helped!

  • How can I define a name in Excel using Powershell?

    I know how to reference existing names using the RANGE function but how can I create a new defined name using Powershell?
    My specific case involves defining a name for a single cell with a workbook scope.  Just as if you were to right-click a cell in Excel and choose Define Name.
    The closest I've gotten is the NAMES object for the workbook but when I "gm" that all I see is a method for delete - nothing for adding.
    $xlsx = "c:\Sample.xlsx"
    $excel = new-object -comobject Excel.Application
    $xlb = $excel.Workbooks.Open($xlsx)
    $xlb.names | gm

    In Excel a Range has a name.  You can create a range and name it.  "Names" is just a list of the names that have been defined.
    So what is it that you are asking?  If your spreadsheet has names this will find them for you.
    Try this:
    $xlb.names|select name
    $r=$xlb.sheets.item(1).UsedRange
    $r.Name='all'
    # now do this again
    $xlb.names|select name
    So now you know everything about "names" or, as us old pros say "named ranges" like in the old  west.
    ¯\_(ツ)_/¯

  • Delete grid row using button in row

    I want to create a grid, with each row containing several
    textInputs and one delete button.
    I will have another button that will add rows to the grid.
    I can't find out how to tie the button in each row to delete
    that row...
    Alos, what is the best way to add a row to the grid ?
    Please advise
    Thanks.

    Hi,
    Why don't you use the function "excel inplace" in the ALV?  With the ALV you have some buttons "SORT/TOTAL/FILTER... and you have PRINT and EXCEL INPLACE"?
    Do you use the method   call method g_grid->set_table_for_first_display in order to display your data alv?
    Best regards

  • Using Powershell Script Run simple query in MS Access 2007 and export the results of query to Excel

    Hi Experts,
    I have a Access 2007 DB file and 2 Big tables inside that (bigger than the size that can be easily handled by MS Excel 2007).
    My requirement is automate using powershell scripts the below things.
    1. Create a SQL query in Access DB and save that in access DB
    2. Run the saved query and export the result in excel sheet where I can create the charts and Pivots. Thanks in advance
    Prajesh

    Do you have to use the Access query, couldn't you just recreate the query in Powershell?  Here's a link with good info that references an existing script for querying an Access database:
    http://blogs.technet.com/b/heyscriptingguy/archive/2009/08/13/hey-scripting-guy-can-i-query-a-microsoft-access-database-with-a-windows-powershell-script.aspx
    Once you have your dataset you can pipe it to
    Export-Csv -NoType c:\pathtofile\output.csv

  • How to delete the row from the ADF table using popup box

    Hi,
    I have one requirement like need to delete a record from the table, but that time need to show one popup window for confirmation of the deletion. I am using Delete buttom from the vo operations. I am able to delete the row with out popup but when i used the popup that time deletion is not happening.
    Can any one help me in this.
    Regards,

    Issue was resolved.

  • Deleting a row from a JTable using AbstractTableModel

    Hi,
    Can someone please help me on how should i go about deleting a row in a jtable using the AbstractTableModel. Here i know how to delete it by using vector as one of the elements in the table. But i want to know how to delete it using an Object[][] as the row field.
    Thanks for the help

    Hi,
    I'm in desperate position for this please help

Maybe you are looking for

  • Broken latch, out of warranty.

    Hello. Sad to report that my almost two year-old 12" PB G4 has experienced a break of the latching mechanism that keeps the lid closed. The hook had been acting strangely for about the past six months but only very recently took to becoming completel

  • Back up software for BB 8900 using macbook air

    Recent;y I have switched onto Mac and although I found syncing software  couldnt manage to find back software. Problem is that I havent backed up my phone for the past 2 months. Does this software exists?  

  • Photoshop 7.0 crashes

    I am a Photoshop 7.0 user on Windows XP. I have used Photoshop 7.0 for several years with pleasing results. Recently my installed version crashes at the same stage of use. I decided to buy a new program CD and uninstalled the original program. After

  • Error when trying to Access Desktop Intelligence..

    Hi everybody I have installed BO XI 3.1 client tools(Designer,deski,webi) on my desktop and server tools on the other machine which is a server. When i am trying to access Deski and webi from my desktop through CMC its giving an error saying that i d

  • Shuts down unexpectedly after an application crashes

    My Macbook Air (iOS 10.9.5, 1.3 GHz, 4 GB) has shut down unexpectedly twice when an application has crashed: first with Firefox (32.0.3) and second with Preview (7.0). With Firefox I was using some regular web apps and browsing sites. With Preview I