Hab mal den Anfang und ein Testbeispiel gemacht.
Es muss noch die Gesamtbreite, die Spaltenbreite und der Übertrag mit einbezogen werden.
Bin dran, nur html ist schon strange :wacko:
Spoiler anzeigen
#include<WindowsConstants.au3>
#include<ListViewConstants.au3>
#include<ButtonConstants.au3>
#include<GUIConstantsEx.au3>
#include<Guilistview.au3>
#include<File.au3>
#include<Array.au3>
Global $sHeader = "Artikelnummer|Art|Nummer|Baureihe|Name|+1" ; Die Überschriften für das Listview und für das "Neuer Eintrag"-Fenster
Global $sDBFile = @ScriptDir & "\datenbank.html" ; Pfad und Name der Datenbank-Datei
If not FileExists($sDBFile) Then _FileCreate($sDBFile)
;global $open = Fileopen($sDBFile,2)
;ConsoleWrite(_ArrayToHTMLTable($a,true,false))
;_FileWriteFromArray($sDBFile,_ArrayToHTMLTable($a,true,false))
;FileWrite($open, _ArrayToHTMLTable($a,true,true))
;MsgBox(1, "",_ArrayToHTMLTable($a,true,true))
#Region Hauptfenster
Global $hGui = GUICreate("Listview-Datenbank-Beispiel", 600, 480) ; Hauptfenster erstellen
Global $hListView = GUICtrlCreateListView($sHeader, 0, 0, 600, 420, $LVS_SHOWSELALWAYS) ; Listview erstellen
Global $hLVHandle = GUICtrlGetHandle($hListView) ; das Handle vom Listview wird für die UDF-Listview-Funktionen benötigt
_GUICtrlListView_SetColumn($hLVHandle, 0, "Artikelnummer", 120, 0)
_GUICtrlListView_SetColumn($hLVHandle, 1, "Art", 60, 0)
_GUICtrlListView_SetColumn($hLVHandle, 2, "Nummer", 90, 0)
_GUICtrlListView_SetColumn($hLVHandle, 3, "Baureihe", 100, 0)
_GUICtrlListView_SetColumn($hLVHandle, 4, "Name", 120, 0)
_GUICtrlListView_SetColumn($hLVHandle, 5, "+1", 12, 0)
for $i = 1 to 20
GUICtrlCreateListViewItem($i &"|Test|2|Uiui|HTML|+1", $hListView)
next
Global $hNew = GUICtrlCreateButton("Print", 5, 430, 80, 35)
GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg(1) ; Message-Event holen (1) = erweiterter Modus
Switch $nMsg[0] ; anhand der Control-ID das entsprechende Case aufrufen
Case $hNew
local $array = _Listviewtoarray($hLVHandle)
_ArrayDisplay($array)
_test($array)
Case $GUI_EVENT_CLOSE ; User hat auf das Schließen-Symbol geklickt (bzw. die ESC-Taste gedrückt)
Switch $nMsg[1] ; erweiterte Abfrage für welches Fenster
Case $hGui ; User will das Hauptfenster schließen
Exit
EndSwitch
EndSwitch
WEnd
Func _Listviewtoarray($hwnd)
local $col, $getcol, $lcount, $atext, $counter = 1
$col = _GUICtrlListView_GetColumnCount($hwnd)
$lcount = _GUICtrlListView_GetItemCount($hwnd)
local $alistview [$lcount+1][$col]
for $y = 0 to $col-1
$getcol= _GUICtrlListView_GetColumn($hwnd, $y)
$alistview[0][$y] = $getcol[5]
next
for $i= 0 to $lcount -1
$atext = _GUICtrlListView_GetItemTextArray($hwnd,$i)
for $x = 0 to $atext[0] -1
$alistview[$counter][$x] = $atext[$x+1]
next
$counter += 1
next
return $alistview
$counter = 1
endfunc
func _test($array)
local $open = Fileopen($sDBFile,2)
local $html = _ArrayToHTMLTable($array,true,true)
FileWrite($open, $html)
fileclose($open)
endfunc
; #FUNCTION# ===================================================================
; Name ..........: _ArrayToHTMLTable
; Description ...: Creates a HTML-table from a 2dim-array
; AutoIt Version : V3.3.0.0
; Syntax ........: _ArrayToHTMLTable(ByRef $aArray[, $bHeader = True[, $bBorder = True[, $sStyle = 'width:100%']]])
; Parameter(s): .: $aArray -
; $bHeader - Optional: (Default = True) :
; $bBorder - Optional: (Default = True) :
; $sStyle - Optional: (Default = width: 100%) : StyleSheet
; Return Value ..: Success - string
; Failure - empty string
; @ERROR -
; Author(s) .....: Thorsten Willert
; Modified ......: Nuts (http://www.autoit.de)
; Date ..........: Wed Jul 01 18:07:39 CEST 2009
; Version .......: 1.0
; ==============================================================================
Func _ArrayToHTMLTable(ByRef $aArray, $bHeader = True, $bBorder = True, $sStyle = 'width:100%')
Local $iD1 = UBound($aArray,1)
If @error Then
SetError(1)
Return ''
EndIf
Local $iD2 = UBound($aArray,2)
If @error Then
SetError(1)
Return ''
EndIf
Local $sTable = ""
If $sStyle <> '' Then $sStyle = ' style="' & $sStyle & '"'
$sStyle &= '>'
If $bBorder Then
$sTable &= '<table border="1"'
Else
$sTable &= '<table'
EndIf
$sTable &= $sStyle & @CRLF
Local $iStart = 0
If $bHeader Then
$iStart = 1
$sTable &= '<tr>' & @CRLF
For $i = 0 To $iD2 -1
$sTable &= @TAB & '<th align="left">' & $aArray[0][$i] & '</th>' & @CRLF
Next
$sTable &= '</tr>' & @CRLF
EndIf
For $i = $iStart To $iD1 -1
$sTable &= '<tr>' & @CRLF
For $j = 0 To $iD2 -1
$sTable &= @TAB & '<td>' & $aArray[$i][$j] & '</td>' & @CRLF
Next
$sTable &= '</tr>' & @CRLF
Next
$sTable &= '</table>' & @CRLF
[/autoit] [autoit][/autoit] [autoit]Return $sTable
EndFunc ;==> _ArrayToHTMLTable