#Include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$ListView1 = GUICtrlCreateListView("C1|C2|C3", 64, 40, 489, 321)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
$ListView1_0 = GUICtrlCreateListViewItem("R1-1|R1-2|R1-3", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("R2-1|R2-2|R2-3", $ListView1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;------------------------------------------------------------------------
FileWrite ( "table.html", _ListViewToHTMLTable($ListView1) )
MsgBox(0,"","请查看:" & @ScriptDir & "\table.html")
Func _ListViewToHTMLTable($hList)
Local $sHTML,$iColCount,$iRowCount
$iColCount = _GUICtrlListView_GetColumnCount($hList)
$sHTML = "<table width='200' border='1'>" & @LF & "<tr>" & @LF
;创建表头
For $i = 0 To $iColCount-1
$aInfo = _GUICtrlListView_GetColumn($hList, $i)
$sHTML = $sHTML & "<th scope='col'>" & $aInfo[5] & "</th>" & @LF
Next
;添加数据
$iRowCount = _GUICtrlListView_GetItemCount($hList)
For $i = 0 To $iRowCount - 1
$sHTML = $sHTML & "<tr>" & @LF
For $j = 0 To $iColCount-1
$aInfo = _GUICtrlListView_GetItem($hList, $i, $j)
$sHTML = $sHTML & "<th>" & $aInfo[3] & "</th>" & @LF
Next
$sHTML = $sHTML & "</tr>" & @LF
Next
$sHTMl = $sHTMl & "</table>"
;MsgBox(0,"",$sHTMl)
Return $sHTML
EndFunc
|