i can help you
do this
#include <Excel.au3>
Func SW2_FileOut()
Local $yy,$xx,$qqq,$aInfo,$Columns,$flag
Local $oExcel = _ExcelBookNew(1)
WinSetState("Microsoft Excel - ","工作表菜单栏",@SW_DISABLE )
_ExcelWriteCell($oExcel, "表名", "A1")
$Columns= _GUICtrlListView_GetColumnCount ($ListView2_1);读取listview的列数
;列名
For $xx=1 To $Columns
$aInfo = _GUICtrlListView_GetColumn($ListView2_1, $xx-1)
_ExcelWriteCell($oExcel, $aInfo[5], 2, $xx)
Next
;内容
For $yy = 3 To _GUICtrlListView_GetItemCount($ListView2_1) + 3
For $xx = 1 To $Columns
$qqq=ControlListView ( "备件管理系统V1.0", "导出EXCEL", 94, "GetText",$yy-3,$xx-1);
;使用ControlListView函数取得当前listview的内容
_ExcelWriteCell($oExcel, $qqq, $yy, $xx)
Next
Next
_ExcelBookSaveAs($oExcel, @ScriptDir&"\"&Random(1,1000)&".xls", "xls", 0, 1);输出一个随机的文件名
WinSetState("Microsoft Excel - ","工作表菜单栏",@SW_ENABLE)
MsgBox(0,"信息提示","完成",1)
EndFunc
这里的WinSetState函数是为了防止在导出过程中由于鼠标的点击,造成输出excel文件终止而产生错误
[ 本帖最后由 ken0137 于 2008-11-5 23:03 编辑 ] |