Beide Richtungen sind möglich.
1. Index
2.
Code
' #########################################
' # Beispiel für die Include Excel2LV.INC #
' # #
' # Zur freien Verwendung für alle! #
' # #
' # 2007 Marc-Gordon Kröhn #
' # http://www.marc-gordon.de #
' # #
' # Benötigt die LiestView.dll von #
' # Frank Abbing http://frabbing.de/ #
' #########################################
$P*
USERMESSAGES 16
' ##### Globale Variablen
Declare close%,L#,Sz&,MerkeX%,MerkeY%,Keyboardstate#,lvdll&,lvliste&,LVFont&,Datei$
' ##### Bereichsvariablen deklarieren
Dim L#,16
Dim Keyboardstate#,256
' ##### Definierte Funktionen
Def GetSysColor(1) !"USER32","GetSysColor"
Def AMoveWindow(6) ! "USER32","MoveWindow","%%%%%%","%"
Def GetKeyboardState(1) ! "USER32.DLL","GetKeyboardState"
' ##### LietView.dll einbinden
lvdll&=usedll("Listview.dll")
$I ListView_Funktionen.inc
Register(123456) ' oder so ähnlich ;-)
' ##### Excel2ListView einbinden
$I Excel2lv.inc
' ##### Setzt in der Statusleiste den Status der Tasten Numlock, Caps und S-Abf
Proc Statustasten
GetKeyboardState(keyboardstate#)
if byte(keyboardstate#,20),1
SetText Sz&,1,"GROSS"
else
SetText Sz&,1,""
endif
if byte(keyboardstate#,144),1
SetText Sz&,2,"NF"
else
SetText Sz&,2,""
endif
if byte(keyboardstate#,145),1
SetText Sz&,3,"SCRL"
else
SetText Sz&,3,""
endif
EndProc
' ##### Aufbau LiestView
Proc ListView
lvliste&=CreateListView(%hwnd,%hinstance,0,$FFFFFF,-1,$31)
ShowListview(lvliste&,0,0,width(%hwnd),height(%hwnd)-25)
SetFont lvliste&,LVFont&
EndProc
' ##### HAUPTFENSTER
Proc Hauptfenster
SetTrueColor 1
WindowStyle $003F
WindowTitle "Excel2ListView"
Window %maxX+10,10-640,480
Cls GetSysColor(15)
UseFont "Arial",16,0,0,0,0
LVFont&=Create("Font","Arial",16,0,0,0,0)
SetDialogFont 1
ListView
Long L#,0 = 500, 545, 570, -1
Sz&=Create("StatusWindow",%HWND,"",4,L#)
SetText Sz&,0,"Bereit"
SetWindowPos %hwnd=((%maxX/2)-320),((%maxY/2)-240)-640,480;0
ShowMax
Update
EndProc
' ##### Öffne Excel
Proc OpenXLS
Declare idx%,x&,Sortierliste$
Datei$=LoadFile$("ÖFFNE","Excel-Arbeitsmappe|*.XLS")
if Datei$=""
else
DeleteAllItems(lvliste&)
EraseListview(lvliste&)
Excel2LV Datei$,"Tabelle1",lvliste& ' Excel-Tabelle, Tabellenname, LV-Handle
WhileNot idx%=GetColumns(lvliste&)
SetColumnWidth(lvliste&,idx%,-1)
Inc idx%
Wend
DeleteColumn (lvliste&,idx%-1)
endif
EndProc
' ##### Update Fenster
Proc Update
if Width(%hwnd)<630
AMoveWindow(%hwnd,%WinLeft,%WinTop,640,%WinBottom-%WinTop,59,1)
elseif Height(%hwnd)<450
AMoveWindow(%hwnd,%WinLeft,%WinTop,%WinRight-%WinLeft,480,59,1)
endif
SetWindowPos Sz&=0,0-0,0;0
MerkeX%=Width(%hwnd)
MerkeY%=Height(%hwnd)
AMoveWindow(lvliste&,0,0,width(%hwnd),height(%hwnd)-25,59,1)
EndProc
' ##### Hauptprogramm
Hauptfenster
Statustasten
OpenXLS
' ##### Hauptprogrammschleife
WhileNot close%
GetMessage
Case %Umessage=16:close%=1
CaseNot MerkeX%=Width(%hwnd):Update
CaseNot MerkeY%=Height(%hwnd):Update
Case Width(%hwnd)<630:Update
Case Height(%hwnd)<450:Update
Case ScanKey(144):Statustasten
Case ScanKey(20):Statustasten
Case ScanKey(145):Statustasten
Wend
' ##### Programmende
Dispose L#
Dispose Keyboardstate#
$I ListView_Dispose.inc
FreeDLL lvdll&
DeleteObject lvfont&
Alles anzeigen