CSV / Excel to Listview

  • Hallo da bin ich mal wieder.

    Ich möchte ien Kalkulationsprogramm schreiben. Ich habe dazu in einer CSV Datei oder als Excel Rechenwerte vorliegen.
    Zb Form
    Col1;Col2;Col3;.....bis Col19
    ItemText;Itemzahl;Itemleer;ItemZahl;Itemleer;.....
    zb
    Zutaten;gewicht;St„rkend;Heilend;Beweglich;Erfrischend;Erhellend;Astralenergetisch;Giftressi;Feuerressi;Wasserrressi;Erdressi;Liftressi;Vergiftend;Entgiftend;Erblindend;Leuchtend;Explodierend;Versteckend;;;;;;;;;;
    Alraune;1;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;0,3;;;;;;;;;;
    Apfelwein;1;0,08;;;;;;;;;;;;0,1;;;;;;;;;;;;;;
    Asche;1,25;;;;;;;;;;0,62;;;0,45;;;;0,24;;;;;;;;;;
    Bambusstock;1;0,27;;;;;;;;;;;;;;;0,1;;;;;;;;;;;


    Das ist der Zustand.
    Ich lese das in ein Array (gesichert auch für die weiterverarbeitung, (glaube ^^)) aus der Excel (zurzeit). Mit ist CSV viel lieber!! Ich hab einiges probiert aber nix half.

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <ListViewConstants.au3>
    #include <StaticConstants.au3>
    #include <TabConstants.au3>
    #include <WindowsConstants.au3>
    #include <Excel.au3>
    #include <Array.au3>

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

    #Region ### START Koda GUI section ### Form=H:\Daimler\Programme (Anwendungen)\PortableApps\AutoIT3\App\AutoIT\Skripte\Pergon Alchemie Kalkulator\Forms\Kalkulator.kxf
    $Form1 = GUICreate("Pergon Alchemie Kalkulator 1.0", 615, 438, 535, 365)
    $Tab1 = GUICtrlCreateTab(8, 8, 601, 425)
    $TabSheet1 = GUICtrlCreateTabItem("Übersicht")
    $csvubersicht = GUICtrlCreateListView("", 16, 40, 586, 390)

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

    Local $sFilePath1 = @ScriptDir & "\Pergon_Alchemie_Kalkulation.xls" ;This file should already exist
    Local $oExcel = _ExcelBookOpen($sFilePath1)
    If @error = 1 Then
    MsgBox(0, "Error!", "Unable to Create the Excel Object")
    Exit
    ElseIf @error = 2 Then
    MsgBox(0, "Error!", "File does not exist - Shame on you!")
    Exit
    EndIf
    Local $aArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
    ;_ArrayDisplay($aArray, "Array using Default Parameters")
    ;19 Colums
    _ExcelBookClose($oExcel) ; And finally we close out
    For $i = 0 to Ubound($aArray) - 1
    GUICtrlCreateListViewItem($aArray[$i][0]&"|"&$aArray[$i][1]&"|"&$aArray[$i][2]&"|"&$aArray[$i][3], $csvubersicht)
    Next

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

    $TabSheet2 = GUICtrlCreateTabItem("Kalkulator")
    $Label1 = GUICtrlCreateLabel("Rezept", 32, 40, 103, 28)
    GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
    $Combo1 = GUICtrlCreateCombo("Combo1", 32, 88, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo2 = GUICtrlCreateCombo("Combo1", 32, 112, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo3 = GUICtrlCreateCombo("Combo1", 32, 136, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo4 = GUICtrlCreateCombo("Combo1", 32, 160, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo5 = GUICtrlCreateCombo("Combo1", 32, 184, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo6 = GUICtrlCreateCombo("Combo1", 32, 208, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo7 = GUICtrlCreateCombo("Combo1", 32, 232, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo8 = GUICtrlCreateCombo("Combo1", 32, 256, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo9 = GUICtrlCreateCombo("Combo1", 32, 280, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo10 = GUICtrlCreateCombo("Combo1", 32, 304, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $ListView1 = GUICtrlCreateListView("", 288, 88, 154, 238)
    $List1 = GUICtrlCreateList("", 184, 88, 97, 240)
    $Label2 = GUICtrlCreateLabel("Wirkungen", 184, 64, 56, 17)
    $Input1 = GUICtrlCreateInput("Input1", 32, 384, 121, 21)
    $Label3 = GUICtrlCreateLabel("Skill höhe des Anwenders", 32, 360, 134, 17)
    $Label4 = GUICtrlCreateLabel("Weitere Werte", 288, 64, 73, 17)
    $TabSheet3 = GUICtrlCreateTabItem("Simulator")
    GUICtrlSetState(-1,$GUI_SHOW)
    $Combo11 = GUICtrlCreateCombo("Combo11", 32, 120, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo12 = GUICtrlCreateCombo("Combo11", 32, 144, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo13 = GUICtrlCreateCombo("Combo11", 32, 168, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Combo14 = GUICtrlCreateCombo("Combo11", 32, 192, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    $Label5 = GUICtrlCreateLabel("Gewünsche Wirkungen", 32, 88, 116, 17)
    $Input2 = GUICtrlCreateInput("Input2", 184, 120, 121, 21)
    $Input3 = GUICtrlCreateInput("Input2", 184, 144, 121, 21)
    $Input4 = GUICtrlCreateInput("Input2", 184, 168, 121, 21)
    $Input5 = GUICtrlCreateInput("Input2", 184, 192, 121, 21)
    $Label6 = GUICtrlCreateLabel("Gewünschte Stärke", 184, 88, 114, 17)
    $Checkbox1 = GUICtrlCreateCheckbox("Werfbar", 80, 216, 97, 17)
    $List2 = GUICtrlCreateList("", 424, 120, 145, 279)
    $Label7 = GUICtrlCreateLabel("Rezept ergebnis", 424, 88, 81, 17)
    $Input6 = GUICtrlCreateInput("Range 1 - 6", 184, 216, 121, 21)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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


    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit


    EndSwitch
    WEnd

    [/autoit]


    Zur Frage:
    Wie lese ich korreckt die CSV aus und lasse die werte für Kontrolle in Listview $csvubersicht ausgeben?

    Mehr nicht ^^

    Einmal editiert, zuletzt von Skar (23. Oktober 2013 um 20:43)

  • Wundervoll. Das ist das was ich gesucht habe ^^. Danke. Da das Portal nicht erreichbar war hatte ich alles fest gecodet im Skript. Vieleicht schreib ich es um bei gelegenheit.