Array durchsuchen und Zählen

  • Hallo gmmg,

    die letzte Version von _GetUsers_Summary berücksichtigt auch Mitarbeiter ohne Zuordnung in der Summierung
    autoit.de/wcf/attachment/12486/
    Um dir diese anzeigen zu lassen musst du nur dein Ausgangsarray nach company sortieren und dies dann mit _ArrayDisplay anzeigen lassen. Die leeren sind am Anfang,

    mfg autoBert

  • Mich würde mal die Laufzeit der Skripte interessieren. Kannst du mal einen Benchmark laufen lassen?

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • hallo UEZ,

    das komplette script läuft aber ca. 25 sek, bis es fertig ist, inklusive schreiben der exceldatei die erstellt wird!!!

    hier der benchmark über die einzelnen AD Site einträge:
    1. version von autoBert, die 2. von dir

    Spoiler anzeigen


    1. version 2. version
    0.0007 s ------ 0.0006 s
    0.005 s ------ 0.0048 s
    0.003 s ------ 0.0028 s
    0.0014 s ------ 0.0012 s
    0.0004 s ------ 0.0002 s
    0.0021 s ------ 0.0017 s
    0.0333 s ------ 0.0238 s
    0.0014 s ------ 0.0012 s
    0.0012 s ------ 0.0008 s
    0.0003 s ------ 0.0002 s
    0.0053 s ------ 0.0052 s
    0.0016 s ------ 0.0013 s
    0.0368 s ------ 0.0265 s
    0.008 s ------ 0.0064 s
    0.9615 s ------ 0.2286 s
    0.0004 s ------ 0.0003 s

    @UAZ deine ist etwas schneller, bringt aber in meinem script noch einen fehler.

    gruß gmmg

    5 Mal editiert, zuletzt von gmmg (3. Februar 2011 um 15:31)

  • Hallo autoBert,

    hab hier gerade ein problem, beim einlesen von XML datein, vielleicht kannst du mal drüberschauen!
    das script läuft schon so halbwegs! hab aber beim 3. oder 4. durchlauf eine dopplung eines wertes!
    in den xml dateinen gibt es immer einen abschnitt <MN20>rufnummer01</MN20> und
    dazugehörige <DESTNAME>zielrufnummer</DESTNAME> einträge (mal einer, mal mehrere!

    was will ich erreichen: es sollen alle <MN20> und die dazugehörigen <DESTNAME>in einer zeile stehen! d.h. im excel spalte 1|2|3 usw.
    dabei sollen doppelte <DESTNAME> nicht mit übernommen werden.

    Spoiler anzeigen
    [autoit]


    #Include <Array.au3>
    #include <file.au3>
    #include <Excel.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aRecords, $avArray_01[1], $avArray_xx[1], $aC, $aCD
    Local $z

    [/autoit] [autoit][/autoit] [autoit]

    $FileList=_FileListToArray(@DesktopDir,"*.xml")
    If @Error=1 Then
    MsgBox (0,"","No Folders Found.")
    Exit
    EndIf
    If @Error=4 Then
    MsgBox (0,"","No Files Found.")
    Exit
    EndIf
    ;_ArrayDisplay($FileList,"$FileList")

    [/autoit] [autoit][/autoit] [autoit]

    ;erstelle excel dokument
    Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

    [/autoit] [autoit][/autoit] [autoit]

    For $z = 1 to $FileList[0]
    ;MsgBox(0,"", $FileList[$z])
    $eintrag = ""
    _test()
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Func _test()

    [/autoit] [autoit][/autoit] [autoit]

    If Not _FileReadToArray(@DesktopDir & "\" & $FileList[$z],$aRecords) Then
    MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
    Exit
    EndIf
    For $x = 1 to $aRecords[0]
    $var = $aRecords[$x]
    $var = StringReplace($var, " ", "")
    $var = StringStripCR($var)
    $var = StringStripWS($var, 3)
    ;Msgbox(0,'Record:' & $x, $aRecords[$x])

    [/autoit] [autoit][/autoit] [autoit]

    IF StringLeft($var, 6) = "<MN20>" Then
    $var01 = $var
    $var01 = StringTrimRight($var01, 7)
    ;Msgbox(0,'Record:' & $x, $var01)
    $var01 = StringTrimLeft($var01, 6)
    ;Msgbox(0,'Record:' & $x, $var01)
    EndIf
    IF StringLeft($var, 10) = "<DESTNAME>" Then
    $var02 = $var
    $var02 = StringTrimRight($var02, 11)
    $var02 = StringTrimLeft($var02, 10)
    ;Msgbox(0,'Record:' & $x, $var01 & "|" & $var02)
    _ArrayAdd($avArray_01, $var01 & "|" & $var02)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;_ArrayDisplay($avArray_01)
    Local $aC = _ArrayUnique($avArray_01)
    _ArrayDelete($aC, 0)
    _ArraySort($aC)
    ;_ArrayDisplay($aC)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To _ArrayMaxIndex($aC, 0, 1)
    ;MsgBox(0,"", _ArrayMin($aC, 0, 1))
    $zeile_1 = $i + 1
    $eintrag = StringSplit($aC[$i], "|")
    _ArrayAdd($avArray_xx, $eintrag[1])
    Next
    Local $aCD = _ArrayUnique($avArray_xx)
    _ArrayDelete($aCD, 0)
    _ArraySort($aCD)
    _ArrayDisplay($aCD, "test")

    [/autoit] [autoit][/autoit] [autoit]

    ;erstelle excel dokument
    ;Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To _ArrayMaxIndex($aC, 0, 1)
    ;MsgBox(0,"", _ArrayMin($aC, 0, 1))
    $zeile_1 = $i
    $eintrag = StringSplit($aC[$i], "|")
    ;MsgBox(0,"",$eintrag[1] & " " & $eintrag[2])
    IF $i = 1 and $aCD[1] = $eintrag[1] Then
    _ExcelWriteCell($oExcel, "'"&$eintrag[1], $zeile_1 + $z, 1)
    _ExcelWriteCell($oExcel, $eintrag[2], $zeile_1 + $z, 2)
    ;MsgBox(0,$i & " 1", $zeile_1 + $z)
    Else
    ;_ExcelWriteCell($oExcel, $eintrag[1], $zeile_1, 3)

    [/autoit] [autoit][/autoit] [autoit]

    _ExcelWriteCell($oExcel, $eintrag[2], $zeile_1 + $z -1 , $i +1)
    ;MsgBox(0,$i &" 2 " & $eintrag[1] , $zeile_1 + $z -1)
    EndIf
    $eintrag[1] = ""
    $eintrag[2] = ""
    ;$oExcel.Range("A"& $zeile_1 &":B"& $zeile_1) .Interior.ColorIndex = 27 ; setze Farbe
    ;$oExcel.Range("A1:B"&$zeile_1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $oExcel.Columns.AutoFit ;AutoFits the Columns for better viewing
    $oExcel.Rows.AutoFit ;AutoFits the Rows for better viewing

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]


    wo könnte der fehler liegen? hab auch mal die excel ausgabe angehangen und das markiert, was da zuviel geschrieben wird!
    ich denke es liegt an einer schleife, denn pro durchlauf sollte immer nur 1 element im array sein, wenn man sich die bilder ansieht, ist aber schon im zweiten durchlauf ein zweites vorhanden!

    danke

    gruß gmmg

  • Hallo gmmg,

    muss dich leider enttäuschen, ich habe kein Excel installiert, aber für XML gibt es ....\AutoIt3\SciTE\cSnippet\includes\_XMLDomWrapper.au3 damit könnte es vielleicht einfacher gehen. Doch damit habe ich mangels XML-Kenntnissen noch nichts gemacht,

    Edit: da dies nicht zum eigentlichen Thema gehört würde ich an deiner Stelle einen neuen Thread eröffnen

    mfg autoBert

  • hallo,

    danke für die antwort!
    das auslesen der xml in ein array ist nicht das problem! sondern eher das unique machen des wertes!

    nur diese stimmen schon nicht (siehe bilder vorheriger post)! da dürfte in bild 2 nur der zweite wert sein

    normalerweise dürfte da immer nur ein wert pro schleifendurchlauf auftauchen!
    das ganze ist gekommen, als ich den ganzen abschnitt _FileListToArray(@DesktopDir,"*.xml") eingebaut habe und der rest in die Func _test() eingekapselt wurde!

    finde aber den fehler nicht, kann aber nur an einer der schleifen liegen!

    ist dem _GetUsers_Summary (vorige posts von dir) ähnlich! damit hattest du mir vor paar tagen geholfen!

    hier nochmal ohne excel und nur mit einem file

    Spoiler anzeigen
    [autoit]


    #Include <Array.au3>
    #include <file.au3>
    ;#include <Excel.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aRecords, $avArray_01[1], $avArray_xx[1], $aC, $aCD
    Local $z

    [/autoit] [autoit][/autoit] [autoit]

    #CS $FileList=_FileListToArray(@DesktopDir,"*.xml",1)
    If @Error=1 Then
    MsgBox (0,"","No Folders Found.")
    Exit
    EndIf
    If @Error=4 Then
    MsgBox (0,"","No Files Found.")
    Exit
    EndIf
    _ArrayDisplay($FileList,"$FileList")

    [/autoit] [autoit][/autoit] [autoit]

    ;erstelle excel dokument
    Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

    [/autoit] [autoit][/autoit] [autoit]

    For $z = 1 to $FileList[0]
    ;MsgBox(0,"", $FileList[$z])
    $eintrag = ""
    _test()
    Next
    #CE
    ;erstelle excel dokument
    ;Local $oExcel = _ExcelBookNew() ;Create new book, make it visible
    _test()

    [/autoit] [autoit][/autoit] [autoit]

    Func _test()

    [/autoit] [autoit][/autoit] [autoit]

    If Not _FileReadToArray(@DesktopDir & "\index2.jsp2.xml",$aRecords) Then
    MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
    Exit
    EndIf
    For $x = 1 to $aRecords[0]
    $var = $aRecords[$x]
    $var = StringReplace($var, " ", "")
    $var = StringStripCR($var)
    $var = StringStripWS($var, 3)
    ;Msgbox(0,'Record:' & $x, $aRecords[$x])

    [/autoit] [autoit][/autoit] [autoit]

    IF StringLeft($var, 6) = "<MN20>" Then
    $var01 = $var
    $var01 = StringTrimRight($var01, 7)
    ;Msgbox(0,'Record:' & $x, $var01)
    $var01 = StringTrimLeft($var01, 6)
    ;Msgbox(0,'Record:' & $x, $var01)
    EndIf
    IF StringLeft($var, 10) = "<DESTNAME>" Then
    $var02 = $var
    $var02 = StringTrimRight($var02, 11)
    $var02 = StringTrimLeft($var02, 10)
    ;Msgbox(0,'Record:' & $x, $var01 & "|" & $var02)
    _ArrayAdd($avArray_01, $var01 & "|" & $var02)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _ArrayDisplay($avArray_01)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aC = _ArrayUnique($avArray_01)
    _ArrayDelete($aC, 0)
    _ArraySort($aC)
    _ArrayDisplay($aC)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To _ArrayMaxIndex($aC, 0, 1)
    ;MsgBox(0,"", _ArrayMin($aC, 0, 1))
    $zeile_1 = $i + 1
    $eintrag = StringSplit($aC[$i], "|")
    _ArrayAdd($avArray_xx, $eintrag[1])
    Next
    Local $aCD = _ArrayUnique($avArray_xx)
    _ArrayDelete($aCD, 0)
    _ArraySort($aCD)
    _ArrayDisplay($aCD, "test")

    [/autoit] [autoit][/autoit] [autoit]

    ;erstelle excel dokument
    ;Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To _ArrayMaxIndex($aC, 0, 1)
    ;MsgBox(0,"", _ArrayMin($aC, 0, 1))
    $zeile_1 = $i
    $eintrag = StringSplit($aC[$i], "|")
    ;MsgBox(0,"",$eintrag[1] & " " & $eintrag[2])
    IF $i = 1 and $aCD[1] = $eintrag[1] Then
    ;---_ExcelWriteCell($oExcel, "'"&$eintrag[1], $zeile_1 + $z, 1)
    ;---_ExcelWriteCell($oExcel, $eintrag[2], $zeile_1 + $z, 2)
    ConsoleWrite("Spalte1=" & $eintrag[1] & " -- Spalte2=" & $eintrag[2] & " -- Spalte3=" & $eintrag[3])
    ;MsgBox(0,$i & " 1", $zeile_1 + $z)
    Else
    ;_ExcelWriteCell($oExcel, $eintrag[1], $zeile_1, 3)

    [/autoit] [autoit][/autoit] [autoit]

    ;---_ExcelWriteCell($oExcel, $eintrag[2], $zeile_1 + $z -1 , $i +1)
    ;MsgBox(0,$i &" 2 " & $eintrag[1] , $zeile_1 + $z -1)
    EndIf
    ;$eintrag[1] = ""
    ;$eintrag[2] = ""
    ;$oExcel.Range("A"& $zeile_1 &":B"& $zeile_1) .Interior.ColorIndex = 27 ; setze Farbe
    ;$oExcel.Range("A1:B"&$zeile_1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;$oExcel.Columns.AutoFit ;AutoFits the Columns for better viewing
    ;$oExcel.Rows.AutoFit ;AutoFits the Rows for better viewing

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]


    im abschnitt _ArrayDisplay($aC) siehst du, das es zwei einträge gibt, die dann gesplittet werden!
    [1]01805111111_Zwansage_1000_1001 | 036-00000-1000
    [2]01805111111_Zwansage_1000_1001 | 036-00000-1001

    der ausgabe strin soll nun wie folgt aussehen:
    01805111111_Zwansage_1000_1001 | 036-00000-1000 | 036-00000-1001

    gruß gmmg

    9 Mal editiert, zuletzt von gmmg (10. Februar 2011 um 21:23)

  • Hallo gmmg,

    teste dieses Skript:

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    #include <file.au3>
    ;#include <Excel.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aRecords, $avArray_01[1], $avArray_xx[1], $aC, $aCD
    Local $z

    [/autoit] [autoit][/autoit] [autoit]

    #CS $FileList=_FileListToArray(@DesktopDir,"*.xml",1)
    If @Error=1 Then
    MsgBox (0,"","No Folders Found.")
    Exit
    EndIf
    If @Error=4 Then
    MsgBox (0,"","No Files Found.")
    Exit
    EndIf
    _ArrayDisplay($FileList,"$FileList")

    [/autoit] [autoit][/autoit] [autoit]

    ;erstelle excel dokument
    Local $oExcel = _ExcelBookNew() ;Create new book, make it visible

    [/autoit] [autoit][/autoit] [autoit]

    For $z = 1 to $FileList[0]
    ;MsgBox(0,"", $FileList[$z])
    $eintrag = ""
    _test()
    Next
    #CE
    ;erstelle excel dokument
    ;Local $oExcel = _ExcelBookNew() ;Create new book, make it visible
    _test()

    [/autoit] [autoit][/autoit] [autoit]

    Func _test()

    [/autoit] [autoit][/autoit] [autoit]

    If Not _FileReadToArray(@DesktopDir & "\index2.jsp2.xml", $aRecords) Then
    MsgBox(4096, "Error", " Error reading log to Array error:" & @error)
    Exit
    EndIf
    For $x = 1 To $aRecords[0]
    $var = $aRecords[$x]
    $var = StringReplace($var, " ", "")
    $var = StringStripCR($var)
    $var = StringStripWS($var, 3)
    ;Msgbox(0,'Record:' & $x, $aRecords[$x])

    [/autoit] [autoit][/autoit] [autoit]

    If StringLeft($var, 6) = "<MN20>" Then
    $var01 = $var
    $var01 = StringTrimRight($var01, 7)
    ;Msgbox(0,'Record:' & $x, $var01)
    $var01 = StringTrimLeft($var01, 6)
    ;Msgbox(0,'Record:' & $x, $var01)
    EndIf
    If StringLeft($var, 10) = "<DESTNAME>" Then
    $var02 = $var
    $var02 = StringTrimRight($var02, 11)
    $var02 = StringTrimLeft($var02, 10)
    ;Msgbox(0,'Record:' & $x, $var01 & "|" & $var02)
    _ArrayAdd($avArray_01, $var01 & "|" & $var02)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _ArrayDelete($avArray_01, 0)
    ;_ArrayDisplay($avArray_01)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aC = _ArrayUnique($avArray_01)
    _ArrayDelete($aC, 0)
    _ArraySort($aC)
    ;_ArrayDisplay($aC)

    [/autoit] [autoit][/autoit] [autoit]

    Dim $avArray_xx[UBound($aC)][2]
    For $i = 0 To UBound($aC) - 1
    $eintrag = StringSplit($aC[$i], "|")
    $avArray_xx[$i][0] = $eintrag[1]
    $avArray_xx[$i][1] = $eintrag[2]
    Next
    ;_ArrayDisplay($avArray_xx, "2D")

    [/autoit] [autoit][/autoit] [autoit]

    $aStringed = _ArrayUnique($avArray_xx)
    _ArrayDelete($aStringed, 0)
    ;_ArrayDisplay($aStringed, "before Stringed")
    For $i = 0 To UBound($aStringed) - 1
    ConsoleWrite($i & @CRLF)
    $aFound = _ArrayFindAll($avArray_xx, $aStringed[$i])
    ;_ArrayDisplay($aFound)
    For $j = 0 To UBound($aFound) - 1
    $iCol = $aFound[$j]
    $aStringed[$i] = $aStringed[$i] & "|" & $avArray_xx[$iCol][1]
    Next
    Next
    _ArrayDisplay($aStringed, "Fertig")
    EndFunc ;==>_test

    [/autoit]

    Ergebnis ist ein 1D Array das durch "|" getrennte Einträge hat: autoit.de/wcf/attachment/12561/

    mfg autoBert

    Einmal editiert, zuletzt von autoBert (10. Februar 2011 um 22:41)

  • Vielleicht mal anders rangegangen:

    Spoiler anzeigen
    [autoit]

    #include <String.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $sDir = @DesktopDir

    [/autoit] [autoit][/autoit] [autoit]

    $FFFF = FileFindFirstFile($sDir & "\*.xml")
    If $FFFF = -1 Then Exit MsgBox(0, "Fehler", "Es wurden keine Dateien/Verzeichnisse gefunden, die zu dem Suchmuster passen")

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $FFNF = FileFindNextFile($FFFF)
    If @error Then ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    $aMN = _StringBetween(FileRead($sDir & "\" & $FFNF), "<MN20>", "</MN20>")
    $aDest = _StringBetween(FileRead($sDir & "\" & $FFNF), "<DESTNAME>","</DESTNAME>")
    $aDest = _ArrayUnique2($aDest)
    If IsArray($aMN) Then ConsoleWrite($aMN[0] & @TAB)
    If IsArray($aDest) Then
    For $i In $aDest
    ConsoleWrite($i & @TAB)
    Next
    EndIf
    ConsoleWrite(@CRLF)
    Until 0

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ArrayUnique2(Const ByRef $aA)
    ; by AspirinJunkie
    Local Static $oD = ObjCreate('Scripting.Dictionary')
    For $i In $aA
    If Not $oD.Exists($i) Then $oD.Add($i, 0)
    Next
    Local $aR = $oD.Keys()
    $oD.RemoveAll
    Return $aR
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von AspirinJunkie (11. Februar 2011 um 00:17)

  • danke euch beiden :)

    hab mich entschlossen mein script zu verwerfen und das von "AspirinJunkie" vorgeschlage zu benutzen!
    hier sind alle von mir gewünschten sachen drin :)

    werd jetzt mal versuchen die ausgabe in excel zu schreiben!

    so, stehe schon vor dem ersten problem! Wie bekomm ich die Werte Konsolenausgabe in ein Array?

    mein versuch schreibt nicht alle werte hintereinander!

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    #include <String.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $sDir = @DesktopDir
    Dim $avArrayXML[1]

    [/autoit] [autoit][/autoit] [autoit]

    $FFFF = FileFindFirstFile($sDir & "\*.xml")
    If $FFFF = -1 Then Exit MsgBox(0, "Fehler", "Es wurden keine Dateien/Verzeichnisse gefunden, die zu dem Suchmuster passen")

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $FFNF = FileFindNextFile($FFFF)
    If @error Then ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    $aMN = _StringBetween(FileRead($sDir & "\" & $FFNF), "<MN20>", "</MN20>")
    $aDest = _StringBetween(FileRead($sDir & "\" & $FFNF), "<DESTNAME>","</DESTNAME>")
    $aDest = _ArrayUnique2($aDest)
    If IsArray($aMN) Then ConsoleWrite($aMN[0] & @TAB)
    If IsArray($aDest) Then
    For $i In $aDest
    ConsoleWrite($i & @TAB)
    Next
    _ArrayAdd($avArrayXML, $aMN[0] & ";" & $i)
    EndIf
    ConsoleWrite(@CRLF)
    ;_ArrayAdd($avArrayXML, $aMN[0] & ";" & $i)
    Until 0

    [/autoit] [autoit][/autoit] [autoit]

    _ArrayDisplay($avArrayXML)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ArrayUnique2(Const ByRef $aA)
    ; by AspirinJunkie
    Local Static $oD = ObjCreate('Scripting.Dictionary')
    For $i In $aA
    If Not $oD.Exists($i) Then $oD.Add($i, 0)
    Next
    Local $aR = $oD.Keys()
    $oD.RemoveAll
    Return $aR
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;#########################################

    [/autoit] [autoit][/autoit] [autoit]

    Konsolenausgabe
    01805605960089-444463-3093
    01805000001089-00000-0001
    01805123334_Zwansage_1000_10010361-51803-10000361-51803-1001
    01805111111_Zwansage_1000_1001036-00000-1000036-00000-1001

    [/autoit] [autoit][/autoit] [autoit]

    Array ausgabe
    [1]|01805605960;089-444463-3093
    [2]|01805000001;089-00000-0001
    [3]|01805123334_Zwansage_1000_1001;0361-51803-1001
    [4]|01805111111_Zwansage_1000_1001;036-00000-1001

    [/autoit] [autoit][/autoit] [autoit][/autoit]


    an welche stelle muss ich hier das _ArrayAdd setzen, das mir alle Werte so wie ind er Konsolenausgabe geschrieben werden?

    hab das jetzt erstmal über filewrite gelöst, ist aber bestimmt zu umständlich!!!

    gruß gmmg

    6 Mal editiert, zuletzt von gmmg (11. Februar 2011 um 10:01)

  • Wolltest du nicht das ganze in eine Excel-Dokument haben?
    Dann brauchst du doch den Umweg über ein Array nicht zu gehen sondern kannst es direkt eintragen:

    Spoiler anzeigen
    [autoit]

    #include <String.au3>
    #include <Array.au3>
    #include <Excel.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $sDir = @DesktopDir

    [/autoit] [autoit][/autoit] [autoit]

    $FFFF = FileFindFirstFile($sDir & "\*.xml")
    If $FFFF = -1 Then Exit MsgBox(0, "Fehler", "Es wurden keine Dateien/Verzeichnisse gefunden, die zu dem Suchmuster passen")

    [/autoit] [autoit][/autoit] [autoit]

    ; erstelle excel dokument
    Global $oExcel = _ExcelBookNew()
    ; Setze Start Reihe und Spalte fest:
    Global $iRow = 2, $iColumn = 2

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $FFNF = FileFindNextFile($FFFF)
    If @error Then ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    $aMN = _StringBetween(FileRead($sDir & "\" & $FFNF), "<MN20>", "</MN20>")
    $aDest = _StringBetween(FileRead($sDir & "\" & $FFNF), "<DESTNAME>","</DESTNAME>")
    $aDest = _ArrayUnique($aDest)

    [/autoit] [autoit][/autoit] [autoit]

    If IsArray($aMN) Then _ExcelWriteCell($oExcel, $aMN[0], $iRow, $iColumn)
    If IsArray($aDest) Then
    For $i = 1 To UBound($aDest) - 1
    _ExcelWriteCell($oExcel, $aDest[$i], $iRow, $i+$iColumn)
    Next
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $iRow += 1
    Until 0

    [/autoit] [autoit][/autoit] [autoit]

    $oExcel.Columns.AutoFit
    $oExcel.Rows.AutoFit

    [/autoit]
  • hallo AspiriJunkie,

    ja, so wollte ich das auch! :)

    mein problem war, dass ich nicht verstanden habe, wie ich die zeile + spalte zuweise, weil es ja am anfang eine For IN schleife war!

    hab nicht gedacht, dass es so einfach ist eine For TO schleife draus zu machen.

    [autoit]


    If IsArray($aMN) Then _ExcelWriteCell($oExcel, $aMN[0], $iRow, $iColumn)
    If IsArray($aDest) Then
    For $i = 1 To UBound($aDest) - 1
    _ExcelWriteCell($oExcel, $aDest[$i], $iRow, $i+$iColumn)
    Next
    EndIf

    [/autoit][autoit][/autoit][autoit]

    $iRow += 1

    [/autoit]

    so funktioniert es aber super!!!

    dank dir :) man lernt halt immer dazu. ;)

    noch eine frage, könnte man das ganze auch um weitere felder ergänzen z.b. <NAME>, welches dann im excel nach dem <DESTNAME> ausgegeben wird?

    Spoiler anzeigen
    [autoit]


    #include <String.au3>
    #include <Array.au3>
    #include <Excel.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $sDir = @DesktopDir

    [/autoit] [autoit][/autoit] [autoit]

    $FFFF = FileFindFirstFile($sDir & "\*.xml")
    If $FFFF = -1 Then Exit MsgBox(0, "Fehler", "Es wurden keine Dateien/Verzeichnisse gefunden, die zu dem Suchmuster passen")

    [/autoit] [autoit][/autoit] [autoit]

    ; erstelle excel dokument
    Global $oExcel = _ExcelBookNew()
    ; Setze Start Reihe und Spalte fest:
    Global $iRow = 2, $iColumn = 1

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $FFNF = FileFindNextFile($FFFF)
    If @error Then ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    $aMN = _StringBetween(FileRead($sDir & "\" & $FFNF), "<MN20>", "</MN20>")
    $aDest00 = _StringBetween(FileRead($sDir & "\" & $FFNF), "<DESTNAME>","</DESTNAME>")
    $aDest00 = _ArrayUnique($aDest00)
    $aDest01 = _StringBetween(FileRead($sDir & "\" & $FFNF), "<NAME>","</NAME>")
    $aDest01 = _ArrayUnique($aDest01)

    [/autoit] [autoit][/autoit] [autoit]

    If IsArray($aMN) Then _ExcelWriteCell($oExcel, "'" & $aMN[0], $iRow, $iColumn)
    If IsArray($aDest00) Then
    For $i = 1 To UBound($aDest00) - 1
    _ExcelWriteCell($oExcel, $aDest00[$i], $iRow, $i+$iColumn)
    Next
    If IsArray($aDest01) Then
    For $i = 1 To UBound($aDest01) - 1
    _ExcelWriteCell($oExcel, $aDest01[$i], $iRow, $i+$iColumn +2)
    Next
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $iRow += 1
    Until 0

    [/autoit] [autoit][/autoit] [autoit]

    $oExcel.Columns.AutoFit
    $oExcel.Rows.AutoFit

    [/autoit]

    hab das mal so gemacht! scheint auch zu funktionieren!

    gruß gmmg

    6 Mal editiert, zuletzt von gmmg (11. Februar 2011 um 12:05)

  • hallo zusammen,

    aus irgendeinem grund geht die funktion _GetUsers_Summary() nicht mehr!
    ich habe folgenden array! hier möchte ich nun über die funktion _GetUsers_Summary() zählen, wie oft jeder eintrag z.b. Operation Management, Reservation vorkommt!

    [autoit]


    ; array $aObjects_01
    [0]|6|3|
    [1]|beyasa|Operation Management|MC
    [2]|beylch|Operation Management|MC
    [3]|beynha|Operation Management|MC
    [4]|beysal||MC
    [5]|beysen|Reservation|MC
    [6]|beyshu||MC

    [/autoit]

    skript

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    $Array_ergebnis = _GetUsers_Summary($aObjects_01)
    If Not @error Then _ArrayDisplay($Array_ergebnis)

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetUsers_Summary(ByRef $aObjects_01)
    If Not IsArray($aObjects_01) Then SetError(1, 0, 0)
    _ArrayDelete($aObjects_01, 0)
    If Not IsArray($aObjects_01) Then SetError(2, 0, 0)
    Local $aCompanies = _ArrayUnique($aObjects_01, 2) ; prüfe feld xy
    _ArrayDelete($aCompanies, 0)
    _ArraySort($aCompanies)
    Local $aResult[UBound($aCompanies)][2]
    For $i = 0 To UBound($aCompanies) - 1
    $aResult[$i][0] = $aCompanies[$i]
    Next
    For $i = 0 To UBound($aResult) - 1
    $aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 2)
    $aResult[$i][1] = UBound($aTemp)
    Next
    Return $aResult
    EndFunc ;==>_GetUsers_Summary

    [/autoit]

    kann da mal bitte einer drüber schauen? die funktion zählt mir nicht mehr, wieviele gleiche einträge in spalte 2 jeweils vorhanden sind (siehe bild2)!

    danke

    gruß gmmg

  • ich teste gerade die funktion schrittweise und finde den fehler nicht! zum einfachen testen, hab ich mal das array gleich mit angehangen!
    bei _ArrayFindAll ist irgendwo der wurm drin :(

    Spoiler anzeigen
    [autoit]


    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ; array $aObjects_01
    Local $aObjects_01[7][3]

    [/autoit] [autoit][/autoit] [autoit]

    $aObjects_01[0][0] = "6"
    $aObjects_01[0][1] = "3"

    [/autoit] [autoit][/autoit] [autoit]

    $aObjects_01[1][0] = "beyasa"
    $aObjects_01[1][1] = "Operation Management"
    $aObjects_01[1][2] = "MC"

    [/autoit] [autoit][/autoit] [autoit]

    $aObjects_01[2][0] = "beylch"
    $aObjects_01[2][1] = "Operation Management"
    $aObjects_01[2][2] = "MC"

    [/autoit] [autoit][/autoit] [autoit]

    $aObjects_01[3][0] = "beynha"
    $aObjects_01[3][1] = "Operation Management"
    $aObjects_01[3][2] = "MC"

    [/autoit] [autoit][/autoit] [autoit]

    $aObjects_01[4][0] = "beysal"
    $aObjects_01[4][1] = ""
    $aObjects_01[4][2] = "MC"

    [/autoit] [autoit][/autoit] [autoit]

    $aObjects_01[5][0] = "beysen"
    $aObjects_01[5][1] = "Reservation"
    $aObjects_01[5][2] = "MC"

    [/autoit] [autoit][/autoit] [autoit]

    $aObjects_01[6][0] = "beyshu"
    $aObjects_01[6][1] = ""
    $aObjects_01[6][2] = "MC"

    [/autoit] [autoit][/autoit] [autoit]

    _ArrayDisplay($aObjects_01)

    [/autoit] [autoit][/autoit] [autoit]

    _GetUsers_Summary($aObjects_01)

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetUsers_Summary(ByRef $aObjects_01)
    If Not IsArray($aObjects_01) Then SetError(1, 0, 0)
    _ArrayDelete($aObjects_01, 0)
    If Not IsArray($aObjects_01) Then SetError(2, 0, 0)
    Local $aCompanies = _ArrayUnique($aObjects_01, 2) ; prüfe feld xy
    _ArrayDelete($aCompanies, 0)
    _ArraySort($aCompanies)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult[UBound($aCompanies)][2]
    For $i = 0 To UBound($aCompanies) - 1
    $aResult[$i][0] = $aCompanies[$i]
    ;MsgBox(0,"", $aResult[$i][0]) ; gibt mir die einzelnen $aCompanies aus
    Next
    _ArrayDisplay($aResult) ;gibt mir die einzelnen $aCompanies im array aus
    ;_ArrayDisplay($aObjects_01)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To UBound($aResult) - 1
    MsgBox(0,"", $aResult[$i][0])
    $aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 2)
    MsgBox(0,"", $aTemp) ; ergebnis -1 , das heißt es gibt hier einen fehler
    $aResult[$i][1] = UBound($aTemp)
    Next
    Return $aResult
    EndFunc ;==>_GetUsers_Summary

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    autoBert kannst du hier helfen?

    vielen dank im vorraus ;)

    gruß gmmg

    7 Mal editiert, zuletzt von gmmg (2. März 2012 um 11:41)

  • [autoit]


    $check = fileread("Mitarbeiter.txt")
    $aFile = StringSplit($check, @CRLF,1)
    Global $aCounts[$aFile[0] + 1]
    Global $iCount = 0

    [/autoit][autoit][/autoit][autoit]

    For $x = 1 To $aFile[0]
    If $aFile[$x] = "" Then ContinueLoop
    $aCounts[$x] = 1
    $iCount += 1
    For $i = $x + 1 To $aFile[0]
    If $aFile[$x] = $aFile[$i] Then
    $aCounts[$x] += 1
    $aFile[$i] = ""
    EndIf
    Next
    Next

    [/autoit][autoit][/autoit][autoit]

    Global $aOutput[$iCount + 1][2]
    $aOutput[0][0] = 1

    [/autoit][autoit][/autoit][autoit]

    For $x = 1 To $aFile[0]
    If $aFile[$x] = "" Then ContinueLoop
    $aOutput[$aOutput[0][0]][0] = $aFile[$x]
    $aOutput[$aOutput[0][0]][1] = $aCounts[$x]
    $aOutput[0][0] += 1
    Next
    Return $aOutput

    [/autoit]

    Die Funktion listet und zählt es zusammen einfach unt Output ist als Arraydisplay

  • @sedas
    wie ist das bei einem mehrdimensionalen array?
    leere zeilen müssen auch gezählt werden!

    mein array habe ich ja unten vorgegeben (dieses wird eigentlich aus dem Active Directory ausgelesen)

    Update:

    [autoit]


    alt: $aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 2)
    neu: $aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 1)

    [/autoit]

    danke allen!

    gruß gmmg :)

    2 Mal editiert, zuletzt von gmmg (2. März 2012 um 11:40)

  • hallo zusammen,

    ich habe ein problem bei folgendem vorhaben! das ganze wird in excel geschrieben und ist schon sehr umfangreich :)

    was bisher funktioniert:
    zählen der user pro department
    zählen der user pro companie

    nun möchte ich aber, die daten so wie im Bild "zuordnung" (siehe anlage) auf dem rechten bildteil zu sehen ist, die companie aufführen und darunter die dazugehörigen departments mit der anzahl der user!
    so wie es im linken bildteil zu sehen ist, habe ich es schon!

    über die _GetUsers_Summary_xxx funktionen wird ja der entsprechende teilabschnitt erstellt ...

    [autoit]


    user1 Department1 Firma1
    user2 Department3 Firma1
    user3 Department2 Firma1
    user4 Department1 Firma2
    user5 Department3 Firma2
    user6 Department1 Firma1
    user7 Department3 Firma3
    user8 Department1 Firma3
    user9 Department3 Firma2

    [/autoit]

    folgend das komplette script

    Spoiler anzeigen
    [autoit]


    #include <Excel.au3>
    #Include <File.au3>
    ;#include <AD.au3>
    #include <D:\Data\scripte\AD_1.1.0_Functions\AD.au3>
    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #Include <Date.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ; excel book erstellen
    ; user nach sites eintragen
    ; user nach company eintragen
    ; user gesamt nach sites eintragen

    [/autoit] [autoit][/autoit] [autoit]

    DIM $oMyRet, $oMyError, $oExcel, $saveas, $sOU, $ld
    Local $avArray[1] ,$avArray_01[1], $alogin[1], $aObjects , $aObjects_01,$aObjects_02, $avArray_10[1],$avArray_11[1], $sValue

    [/autoit] [autoit][/autoit] [autoit]

    $longonserver = StringReplace(@LogonServer,"\\","")

    [/autoit] [autoit][/autoit] [autoit]

    _AD_Open()

    [/autoit] [autoit][/autoit] [autoit]

    ;------list dc's----
    Local $aDC = _AD_ListDomainControllers()
    _ArraySort($aDC)
    ;_ArrayDisplay($aDC, "Active Directory Functions - Example 1 - All Domain Controllers, distinguished name, DNS host name, and the site name")

    [/autoit] [autoit][/autoit] [autoit]

    ;auslesen der einzelnen OU's
    $aOUs = _AD_GetObjectsInOU($sOU, "(objectCategory=organizationalUnit)", 1, "name") ;"distinguishedName")
    If @error > 0 Then
    MsgBox(64, "Active Directory Functions - Example 2", "No OUs could be found")
    Else
    ;_ArrayDisplay($aOUs, "Active Directory Functions - Example 2 - All OUs starting with: '" & $sOU & "'")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;---------------------------------
    ;_ArrayDelete($aOUs, 0) ;löscht 1 eintrag aus dem array
    _ArraySort($aOUs)
    ;_ArrayDisplay($aOUs, "AD all Site OUs!")

    [/autoit] [autoit][/autoit] [autoit]

    $site = InputBox("Site","Input - AD Site Name" & @CRLF & @CRLF & "e.g. xxx01 or xxx02...")
    IF @error = 1 Then Exit

    [/autoit] [autoit][/autoit] [autoit]

    ;erstelle excel dokument
    Local $oExcel = _ExcelBookNew() ;Create new book, make it visible
    _ExcelSheetDelete($oExcel, "Sheet1") ;Delete Sheet by string name of SheetName
    _ExcelSheetDelete($oExcel, "Sheet2") ;Delete Sheet by string name of SheetName
    _ExcelSheetDelete($oExcel, "Sheet3") ;Delete Sheet by string name of SheetName
    _ExcelSheetDelete($oExcel, "Tabelle1") ;Delete Sheet by string name of SheetName
    _ExcelSheetDelete($oExcel, "Tabelle2") ;Delete Sheet by string name of SheetName
    ;-----------------------
    Sleep(1000)

    [/autoit] [autoit][/autoit] [autoit]

    $x = 1
    $aOUs[$x] = StringUpper($site)

    [/autoit] [autoit][/autoit] [autoit]

    ;For $x = 1 to $aOUs[0]
    $ld = ""
    $aObjects = _AD_GetObjectsInOU("OU=User,OU="&$aOUs[$x]&",DC=xx,DC=int", "(&(objectcategory=person)(objectclass=user)(mail=*)(|(userAccountControl=512)(msExchHideFromAddressLists="")(msExchHideFromAddressLists=FALSE)(userAccountControl=66048)))", 2, "name,department,company")
    $aObjects_01 = $aObjects
    $aObjects_02 = $aObjects
    $aObjects_03 = $aObjects
    _ArrayDisplay($aObjects_01)

    [/autoit] [autoit][/autoit] [autoit]

    If @error > 0 Then
    ;MsgBox(64, $aOUs[$x], "Nichts gefunden Error: " & @error)
    Else
    ;$bench = TimerInit() ; laufzeittest
    ;--user pro company in site zählen-----
    $Array_05 = _GetUsers_Summary1($aObjects_01) ;dieses Array enthält die Ergebnisse
    $Array_06 = _GetUsers_Summary2($aObjects_02) ;dieses Array enthält die Ergebnisse
    $Array_07 = _GetUsers_Summary3($aObjects_03) ;dieses Array enthält die Ergebnisse
    If Not @error Then _ArrayDisplay($Array_05)
    ;If Not @error Then _ArrayDisplay($Array_06)
    ;If Not @error Then _ArrayDisplay($Array_07)
    ;If Not @error Then _ArrayDisplay($avArray_10)
    ;ConsoleWrite(Round(TimerDiff($bench) / 1000, 4) & " s" & @CRLF) ; laufzeittest ausgabe
    ;--------------------------------------
    _ExcelSheetAddNew($oExcel, $aOUs[$x])
    _ExcelWriteCell($oExcel, "User", 1, 1) ;Write to the Cell
    _ExcelWriteCell($oExcel, "Department", 1, 2) ;Write to the Cell
    _ExcelWriteCell($oExcel, "Company", 1, 3) ;Write to the Cell
    ;Zusätzliche Spalten
    _ExcelWriteCell($oExcel, "Exist Yes", 1, 4) ;Write to the Cell
    _ExcelWriteCell($oExcel, "Exist No", 1, 5) ;Write to the Cell
    _ExcelWriteCell($oExcel, "Comments", 1, 6) ;Write to the Cell
    $oExcel.Columns("A:A").ColumnWidth = "30" ;setze spaltenbreite
    $oExcel.Columns("B:B").ColumnWidth = "50" ;setze spaltenbreite
    $oExcel.Columns("C:C").ColumnWidth = "25" ;setze spaltenbreite
    ;---------------------------------------------------------------
    $oExcel.Columns("D:D").ColumnWidth = "10" ;setze spaltenbreite
    $oExcel.Columns("E:E").ColumnWidth = "10" ;setze spaltenbreite
    $oExcel.Columns("F:F").ColumnWidth = "13" ;setze spaltenbreite
    ;---------------------------------------------------------------
    $oExcel.Range("A1:F1") .Font.Bold = TRUE ; setze schriftgrad
    $oExcel.Range("A1:F1") .Font.Size = 14 ; setze schriftgröße
    ;$oExcel.Range("A1:D1") .Font.Color = 0xffffff
    $oExcel.Range("A1:F1") .Interior.ColorIndex = 43 ; setze Farbe
    ;$oExcel.Name = $aOUs[$x]

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $aObjects[0][0]
    ;MsgBox(0,"", $aObjects[$i][0])
    $zeile = $i + 1
    IF $aObjects[0][0] <> "" Then
    ;MsgBox(0,"", $aObjects[$i][0])
    _ExcelWriteCell($oExcel, $aObjects[$i][0], $zeile, 1)
    _ExcelWriteCell($oExcel, $aObjects[$i][1], $zeile, 2)
    _ExcelWriteCell($oExcel, $aObjects[$i][2], $zeile, 3)
    $oExcel.Range("A"& $zeile &":F"& $zeile) .Interior.ColorIndex = 27 ; setze Farbe gelb
    $oExcel.Range("A1:F"&$zeile).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    EndIf
    Next
    ;_ArrayAdd($avArray, $aOUs[$x] & ";" & $aObjects[0][0] - $ld) ; füge in array für Excelsheet "ZGesamt" ein
    _ArrayAdd($avArray, $aOUs[$x] & ";" & $aObjects[0][0] & ";" & $ld & ";" & $aObjects[0][0] - $ld) ; füge in array für Excelsheet "ZGesamt" ein
    ;_ArrayDisplay($avArray)
    _ExcelWriteCell($oExcel, $aObjects[0][0], $zeile + 2, 2)
    _ExcelWriteCell($oExcel, "All USER " & $aOUs[$x] & ":", $zeile + 2, 1)

    [/autoit] [autoit][/autoit] [autoit]

    $oExcel.Range("A"& $zeile +2 &":B"& $zeile+2) .Interior.ColorIndex = 27 ; setze Farbe
    $oExcel.Range("A1:B"&$zeile +2).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    $oExcel.Range("A"& $zeile +2 &":B"& $zeile+2) .Font.Bold = TRUE ; setze schriftgrad

    [/autoit] [autoit][/autoit] [autoit]

    #Region ----Excel_Sheet_Summary ----
    ;-------schreibe user pro company in excelsheet = sheet summary-------
    $yearsheet = "Summary" & _NowDate()
    _ExcelSheetAddNew($oExcel, $yearsheet) ; erstelle neues sheet "jahresdatum"
    $oExcel.Range("A1:B1").Select ; cell selection
    $oExcel.Selection.Merge ; merge cell selection
    $oExcel.Selection.HorizontalAlignment = -4108 ; setze schrift in zelle zentriert
    $zeile = 1
    _ExcelWriteCell($oExcel, "Active User Validation " & $aOUs[$x], $zeile, 1)
    $oExcel.Range("A1:A1").Interior.ColorIndex = 36 ; setze Farbe hellgelb
    $oExcel.Range("A1:A1").Font.Bold = TRUE ; setze schriftgrad
    $oExcel.Range("A1:A1").Font.Size = 12 ; setze schriftgröße
    ;------------------
    _ExcelWriteCell($oExcel, "Total User " & $aOUs[$x] & ":", $zeile + 2, 1)
    _ExcelWriteCell($oExcel, $aObjects[0][0], $zeile + 2, 2)
    $oExcel.Range("A" & $zeile + 2 & ":B" & $zeile + 2).Interior.ColorIndex = 36 ; setze Farbe hellgelb
    $oExcel.Range("A" & $zeile + 2 & ":B" & $zeile + 2).Font.Bold = TRUE ; setze schriftgrad
    ;$oExcel.Range("A" & $zeile + 2 & ":B" & $zeile + 2).Font.Size = 12 ; setze schriftgröße
    ;--------------------------------------------------------
    For $i = 0 To UBound($Array_05) - 1
    ;MsgBox(0,"", $Array_05[$i][0] & " " &$Array_05[$i][1])
    IF $Array_05[$i][0] = "" Then
    ;MsgBox(0,"",$Array_05[$i][1])
    _ExcelWriteCell($oExcel,"No Department", $zeile + 4 + $i, 1)
    Else
    _ExcelWriteCell($oExcel, $Array_05[$i][0], $zeile + 4 + $i, 1)
    EndIf
    _ExcelWriteCell($oExcel, $Array_05[$i][1], $zeile + 4 + $i, 2)
    ;$oExcel.Range("A"& $zeile + 4 + $i &":B"& $zeile + 4 + $i) .Interior.ColorIndex = 27 ; setze Farbe gelb
    $oExcel.Range("A1:B"&$zeile + 4 + $i).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    $oExcel.Range("A"& $zeile + 4 +$i &":B"& $zeile + 4 +$i) .Font.Bold = TRUE ; setze schriftgrad
    $oExcel.Columns("A:A").ColumnWidth = "50" ;setze spaltenbreite
    IF $aObjects[0][0] <> "" Then _ArrayAdd($avArray_01, $aOUs[$x] & ";" & $Array_05[$i][0] & ";" & $Array_05[$i][1]) ; füge daten in array für YGesamt
    Next
    $zeile = $zeile + 4 + $i

    [/autoit] [autoit][/autoit] [autoit]

    If $aObjects <> "" Then _ArrayAdd($avArray_01, ";;")
    ;-------------------------------------------------------
    ;MsgBox(0,"",$zeile)
    ;--------companie zeilen schreiben ----------
    For $i = 0 To UBound($Array_07) -1
    IF $Array_07[$i][0] = "" Then
    ;MsgBox(0,"","test")
    _ExcelWriteCell($oExcel,"No Companie", $zeile + 2 + $i, 1)
    _ExcelWriteCell($oExcel, $Array_07[$i][1], $zeile + 2 + $i, 2)
    $oExcel.Range("A"& $zeile + 2 + $i &":B"& $zeile + 2 + $i) .Interior.ColorIndex = 36 ; setze Farbe gelb
    Else
    _ExcelWriteCell($oExcel, $Array_07[$i][0], $zeile + 2 + $i, 1)
    _ExcelWriteCell($oExcel, $Array_07[$i][1], $zeile + 2 + $i, 2)
    $oExcel.Range("A"& $zeile + 2 + $i &":B"& $zeile + 2 + $i) .Interior.ColorIndex = 36 ; setze Farbe gelb
    EndIf
    ;_ExcelWriteCell($oExcel, $Array_07[$i][0], $zeile + 2 + $i, 1)
    ;_ExcelWriteCell($oExcel, $Array_07[$i][1], $zeile + 2 + $i, 2)
    ;$oExcel.Range("A"& $zeile + 4 + $i &":B"& $zeile + 4 + $i) .Interior.ColorIndex = 27 ; setze Farbe gelb
    $oExcel.Range("A1:B"&$zeile + 2 + $i).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    $oExcel.Range("A"& $zeile + 2 +$i &":B"& $zeile + 2 +$i) .Font.Bold = TRUE ; setze schriftgrad
    $oExcel.Columns("A:A").ColumnWidth = "50" ;setze spaltenbreite
    Next
    #EndRegion ----Excel_Sheet_Summary----
    EndIf
    ;Next

    [/autoit] [autoit][/autoit] [autoit]

    _AD_Close()

    [/autoit] [autoit][/autoit] [autoit]

    ;_ExcelSort($oExcel, "A2","A1",1,1,1,1) ; to sort just the A column A->Z

    [/autoit] [autoit][/autoit] [autoit]

    _ExcelSheetDelete($oExcel, "Tabelle3") ;Delete Sheet by string name of SheetName
    _ExcelSheetAddNew($oExcel, "YGesamt")
    _ExcelSheetAddNew($oExcel, "ZGesamt")
    _ExcelSheetOrderByName($oExcel, 0)

    [/autoit] [autoit][/autoit] [autoit]

    #Region ZGesamt
    ;---------ZGesamt-------------------------
    _ExcelWriteCell($oExcel, "Site", 1, 1) ;Write to the Cell
    _ExcelWriteCell($oExcel, "User", 1, 2) ;Write to the Cell
    ;_ExcelWriteCell($oExcel, "User inaktiv", 1, 3) ;Write to the Cell
    ;_ExcelWriteCell($oExcel, "Anzahl bereinigt", 1, 4) ;Write to the Cell
    _ExcelSheetActivate($oExcel, "ZGesamt")
    $oExcel.Columns("A:A").ColumnWidth = "30" ;setze spaltenbreite
    $oExcel.Columns("B:B").ColumnWidth = "30" ;setze spaltenbreite
    ;$oExcel.Columns("C:C").ColumnWidth = "30" ;setze spaltenbreite
    ;$oExcel.Columns("D:D").ColumnWidth = "30" ;setze spaltenbreite
    $oExcel.Range("A1:B1") .Font.Bold = TRUE ; setze schriftgrad
    $oExcel.Range("A1:B1") .Font.Size = 14 ; setze schriftgröße
    ;$oExcel.Range("A1:D1") .Font.Color = 0xffffff
    $oExcel.Range("A1:B1") .Interior.ColorIndex = 43 ; setze Farbe
    ;$oExcel.Name = $aOUs[$x]

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To _ArrayMaxIndex($avArray, 0, 1)
    ;MsgBox(0,"", $avArray[$i])
    $zeile_1 = $i + 1
    $eintrag = StringSplit($avArray[$i], ";")
    _ExcelWriteCell($oExcel, $eintrag[1], $zeile_1, 1)
    _ExcelWriteCell($oExcel, $eintrag[2], $zeile_1, 2)
    ;_ExcelWriteCell($oExcel, $eintrag[3], $zeile_1, 3)
    ;_ExcelWriteCell($oExcel, $eintrag[4], $zeile_1, 4)
    $oExcel.Range("A"& $zeile_1 &":B"& $zeile_1) .Interior.ColorIndex = 27 ; setze Farbe
    $oExcel.Range("A1:B"&$zeile_1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _ExcelWriteCell($oExcel, "=Summe(B2:B"& $zeile_1 ,$zeile_1 + 1 , 2) ;Write formula another way Uses A1 referencing, not R1C1
    ;_ExcelWriteCell($oExcel, "=Summe(C2:C"& $zeile_1 ,$zeile_1 + 1 , 2) ;Write formula another way Uses A1 referencing, not R1C1
    ;_ExcelWriteCell($oExcel, "=Summe(D2:D"& $zeile_1 ,$zeile_1 + 1 , 2) ;Write formula another way Uses A1 referencing, not R1C1
    _ExcelWriteCell($oExcel, "All User",$zeile_1 + 1 , 1) ;Write formula another way Uses A1 referencing, not R1C1
    ; formatiert letzte Zeile
    $oExcel.Range("A"& $zeile_1 +1 &":B"& $zeile_1 + 1) .Interior.ColorIndex = 27 ; setze Farbe
    $oExcel.Range("A"& $zeile_1 +1 &":B"& $zeile_1 + 1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
    $oExcel.Range("A"& $zeile_1 +1 &":B"& $zeile_1 + 1) .Font.Bold = TRUE ; setze schriftgrad

    [/autoit] [autoit][/autoit] [autoit]

    ;---------Ende ZGesamt---------------------
    #EndRegion ZGesamt
    #Region YGesamt
    ;---------YGesamt--------------------------
    _ExcelSheetActivate($oExcel, "YGesamt")
    _ExcelWriteCell($oExcel, "Site", 1, 1) ;Write to the Cell
    _ExcelWriteCell($oExcel, "Departments", 1, 2) ;Write to the Cell
    ;_ExcelWriteCell($oExcel, "User", 1, 3) ;Write to the Cell
    _ExcelSheetActivate($oExcel, "YGesamt")
    $oExcel.Columns("A:A").ColumnWidth = "25" ;setze spaltenbreite
    $oExcel.Columns("B:B").ColumnWidth = "30" ;setze spaltenbreite
    ;$oExcel.Columns("C:C").ColumnWidth = "20" ;setze spaltenbreite
    $oExcel.Range("A1:B1") .Font.Bold = TRUE ; setze schriftgrad
    $oExcel.Range("A1:B1") .Font.Size = 14 ; setze schriftgröße
    ;$oExcel.Range("A1:D1") .Font.Color = 0xffffff
    $oExcel.Range("A1:B1") .Interior.ColorIndex = 43 ; setze Farbe
    ;$oExcel.Name = $aOUs[$x]

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To _ArrayMaxIndex($avArray_10, 0, 1)
    ;IF $aObjects[0][0] <> "" Then
    $zeile_1 = $i + 1
    $eintrag = StringSplit($avArray_10[$i], ";")
    _ExcelWriteCell($oExcel, $eintrag[1], $zeile_1, 1)
    _ExcelWriteCell($oExcel, $eintrag[2], $zeile_1, 2)
    ;_ExcelWriteCell($oExcel, $eintrag[3], $zeile_1, 3)
    If $eintrag[1] = "" Then
    $oExcel.Range("A"& $zeile_1 &":B"& $zeile_1).Interior.ColorIndex = 43 ; setze Farbe
    _ExcelWriteCell($oExcel, $eintrag[2], $zeile_1, 3)
    Else
    $oExcel.Range("A"& $zeile_1 &":B"& $zeile_1).Interior.ColorIndex = 27 ; setze Farbe
    EndIf
    $oExcel.Range("A1:B"&$zeile_1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen

    [/autoit] [autoit][/autoit] [autoit]

    Next
    ;---------Ende YGesamt---------------------
    #EndRegion YGesamt

    [/autoit] [autoit][/autoit] [autoit]

    _ExcelSheetActivate($oExcel,$yearsheet)
    ;_ArrayDisplay($alogin)

    [/autoit] [autoit][/autoit] [autoit]

    ;$saveas = "C:\User_in Sites"
    ;_ExcelBookSaveAs($oExcel, $saveas, "xls")
    ;_ExcelBookClose($oExcel, 1, 0)

    [/autoit] [autoit][/autoit] [autoit]

    #Region Funtions
    ;===============================================================================
    ; Function Name: _ExcelSheetOrderByName($oExcel, $iDesc=0)
    ; Description:: Order ExcelBook-Sheets by name ascending (default) or descending
    ; Parameter(s): $oExcel - Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew()
    ; $iDesc - order descending on=1/off=0 (default)
    ; Requirement(s): #Include <Array.au3>
    ; Return Value(s): On Success - Returns 1
    ; On Failure - Returns 0 and sets @error=1 - Specified object does not exist
    ; Author(s): BugFix ([email='bugfix@autoit.de'][/email])
    ;===============================================================================
    Func _ExcelSheetOrderByName($oExcel, $iDesc=0)
    If Not IsObj($oExcel) Then Return SetError(1, 0, 0)
    If $iDesc <> 1 Then $iDesc = 0
    Local $aList = _ExcelSheetList($oExcel)
    _ArraySort($aList, $iDesc)
    Local $pos = 1
    For $i = 0 To UBound($aList) -1
    If $i = 0 Then
    _ExcelSheetMove($oExcel, $aList[$i], $pos, True)
    Else
    _ExcelSheetMove($oExcel, $aList[$i], $pos, False)
    $pos += 1
    EndIf
    Next
    Return 1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetUsers_Summary1(ByRef $aObjects_01)
    If Not IsArray($aObjects_01) Then SetError(1, 0, 0)
    _ArrayDelete($aObjects_01, 0)
    ;_ArrayDisplay($aObjects_01)
    If Not IsArray($aObjects_01) Then SetError(2, 0, 0)
    Local $aCompanies = _ArrayUnique($aObjects_01, 2) ; prüfe feld xy
    _ArrayDelete($aCompanies, 0)
    _ArraySort($aCompanies)
    _ArrayDisplay($aCompanies)
    Local $aResult[UBound($aCompanies)][2]
    For $i = 0 To UBound($aCompanies) - 1
    $aResult[$i][0] = $aCompanies[$i]
    Next

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To UBound($aResult) - 1
    ;$aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 2)
    $aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 1)
    $aResult[$i][1] = UBound($aTemp)
    Next
    Return $aResult
    EndFunc ;==>_GetUsers_Summary 1

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetUsers_Summary2(ByRef $aObjects_02) ; Companies
    If Not IsArray($aObjects_02) Then SetError(1, 0, 0)
    _ArrayDelete($aObjects_02, 0)
    ;_ArrayDisplay($aObjects_02)
    If Not IsArray($aObjects_02) Then SetError(2, 0, 0)
    Local $aCompanies = _ArrayUnique($aObjects_02, 2) ; prüfe feld xy
    _ArrayDelete($aCompanies, 0)
    _ArraySort($aCompanies)
    ;_ArrayDisplay($aCompanies)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To UBound($aCompanies) - 1
    _ArrayAdd($avArray_10,$aOUs[$x] & ";" & $aCompanies[$i]) ;erstelle array "$avArray_10"
    Next
    If $aObjects_02 <> "" Then _ArrayAdd($avArray_10, ";;")
    EndFunc ;==>_GetUsers_Summary 2

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetUsers_Summary3(ByRef $aObjects_03) ;Departments zählen
    If Not IsArray($aObjects_03) Then SetError(1, 0, 0)
    _ArrayDelete($aObjects_03, 0)
    ;_ArrayDisplay($aObjects_03)
    If Not IsArray($aObjects_03) Then SetError(2, 0, 0)
    Local $aDepartments = _ArrayUnique($aObjects_03, 3) ; prüfe feld xy
    _ArrayDelete($aDepartments, 0)
    _ArraySort($aDepartments)
    ;_ArrayDisplay($aDepartments)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult1[UBound($aDepartments)][2]
    For $i = 0 To UBound($aDepartments) - 1
    $aResult1[$i][0] = $aDepartments[$i]
    Next

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To UBound($aResult1) - 1
    ;$aTemp1 = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 2)
    $aTemp1 = _ArrayFindAll($aObjects_03, $aResult1[$i][0], 0, 0, 0, 0, 2)
    $aResult1[$i][1] = UBound($aTemp1)
    Next
    Return $aResult1
    EndFunc ;==>_GetUsers_Summary 3

    [/autoit] [autoit][/autoit] [autoit]

    ;_ExcelSort($oExcel, "A1","A1",1,1,1,1) ; to sort just the A column A->Z

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Description: Performs a simplified sort on a range.
    ; Syntax: _ExcelSort($oExcel, $sKey, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iDirection = 2)
    ; Parameter(s): $oExcel - An Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew()
    ; $sKey - The key column or row to sort by (a letter for column, a number for row)
    ; $sRangeOrRowStart - Either an A1 range, or an integer row number to start from if using R1C1
    ; $iColStart - The starting column for the number format(left) (default=1)
    ; $iRowEnd - The ending row for the number format (bottom) (default=1)
    ; $iColEnd - The ending column for the number format (right) (default=1)
    ; $iDirection - Sort direction (1=Ascending, 2=Descending) (default=descending)
    ; Requirement(s): None
    ; Return Value(s): On Success - Returns 1
    ; On Failure - Returns 0 and sets @error on errors:
    ; @error=1 - Specified object does not exist
    ; @error=2 - Starting row or column invalid
    ; @extended=0 - Starting row invalid
    ; @extended=1 - Starting column invalid
    ; @error=3 - Ending row or column invalid
    ; @extended=0 - Ending row invalid
    ; @extended=1 - Ending column invalid
    ; Author(s): SEO <locodarwin at yahoo dot com>, many thanks to DaLiMan
    ; Note(s): This sort routine will not function properly with pivot tables. Please
    ; use the pivot table sorting functions instead.
    ;
    ;===============================================================================
    Func _ExcelSort($oExcel, $sKey, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iDirection = 2)
    If NOT IsObj($oExcel) Then Return SetError(1, 0, 0)
    If NOT StringRegExp($sRangeOrRowStart, "[A-Z,a-z]", 0) Then
    If $sRangeOrRowStart < 1 Then Return SetError(2, 0, 0)
    If $iColStart < 1 Then Return SetError(2, 1, 0)
    If $iRowEnd < $sRangeOrRowStart Then Return SetError(3, 0, 0)
    If $iColEnd < $iColStart Then Return SetError(3, 1, 0)
    $oExcel.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd)).Sort _
    ($oExcel.Range($sKey), $iDirection)
    Else
    $oExcel.Range($sRangeOrRowStart).Sort ($oExcel.Range($sKey), $iDirection)
    EndIf
    Return 1
    EndFunc ;==>_ExcelSort
    #EndRegion Funtions

    [/autoit]

    vielleicht hat ja einer eine spontane idee?

    danke

    gruß gmmg