#include <Excel.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
Local $ListView[2], $Test[2] = ["ID1|NAME1|OTHER1", "ID2|NAME2|OTHER2"]
$Form1 = GUICreate("Form1", 623, 444, 192, 124)
$Tab1 = GUICtrlCreateTab(32, 32, 545, 337)
$TabSheet1 = GUICtrlCreateTabItem("分页1")
$ListView[0] = GUICtrlCreateListView($Test[0], 40, 64, 530, 294)
GUICtrlCreateListViewItem('1|张三|65786315', $ListView[0])
GUICtrlCreateListViewItem('2|李四|56454688', $ListView[0])
GUICtrlCreateListViewItem('3|王五|86575765', $ListView[0])
GUICtrlCreateListViewItem('4|孙六|87654832', $ListView[0])
GUICtrlCreateListViewItem('5|赵七|96325478', $ListView[0])
GUICtrlCreateListViewItem('6|成八|64651873', $ListView[0])
GUICtrlCreateListViewItem('7|冯九|96437251', $ListView[0])
GUICtrlCreateListViewItem('8|钱十|64976835', $ListView[0])
$TabSheet2 = GUICtrlCreateTabItem("分页2")
$ListView[1] = GUICtrlCreateListView($Test[1], 40, 64, 529, 297)
GUICtrlCreateListViewItem('1|张三|65786315', $ListView[1])
GUICtrlCreateListViewItem('2|李四|56454688', $ListView[1])
GUICtrlCreateListViewItem('3|王五|86575765', $ListView[1])
GUICtrlCreateListViewItem('4|孙六|87654832', $ListView[1])
GUICtrlCreateListViewItem('5|赵七|96325478', $ListView[1])
GUICtrlCreateListViewItem('6|成八|64651873', $ListView[1])
GUICtrlCreateListViewItem('7|冯九|96437251', $ListView[1])
GUICtrlCreateListViewItem('8|钱十|64976835', $ListView[1])
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("to Excel", 40, 384, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Local $array[1]
For $i = 0 To UBound($ListView) - 1
$Count = _GUICtrlListView_GetItemCount($ListView[$i])
_ArrayAdd($array, $Test[$i])
If $Count <> 0 Then
For $ii = 0 To $Count - 1
_ArrayAdd($array, _GUICtrlListView_GetItemTextString($ListView[$i], $ii))
Next
EndIf
Next
$excel = _ExcelBookNew(1)
For $i = 1 To UBound($array) - 1
$htest = StringSplit($array[$i], "|")
For $ii = 0 To $htest[0]
_ExcelWriteCell($excel, $htest[$ii], $i, $ii)
Next
Next
EndSwitch
WEnd
|