#include <Excel.au3>
#include <Array.au3>
#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <ListboxConstants.au3>
#include <EditConstants.au3>
#Include <File.au3>
#include <GuiEdit.au3>
#include <ScrollBarConstants.au3>
$Form1_1 = GUICreate("", 700, 400, 195, 125)
GUICtrlSetFont($Form1_1, 20)
$Button2 = GUICtrlCreateButton("开始", 450, 350, 60, 30, 0)
$Button3 = GUICtrlCreateButton("退出", 550, 350, 60, 30, 0)
$Group1 = GUICtrlCreateGroup("", 20, 80, 340, 308)
$mylist = GUICtrlCreateEdit("", 400, 160, 280, 167,BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL))
$Label4 = GUICtrlCreateLabel("详细过程:", 400, 140, 150, 17)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
_Do();生成新的工作表并进行计算
Case $Button3
Exit
EndSwitch
WEnd
Func _Do()
$oExcel1 = _ExcelBookOpen(@ScriptDir&"\aaa.xls",0)
$aArray = _ExcelSheetList($oExcel1)
_GUICtrlEdit_Scroll($mylist,$SB_LINEDOWN)
GUICtrlSetData($mylist, "此表包含"&$aArray[0]&"个工作表"&@CRLF,1)
For $i = $aArray[0] To 1 Step -1
_ExcelSheetActivate($oExcel1, $i)
$c=_ExcelSheetNameGet($oExcel1)
_GUICtrlEdit_Scroll($mylist,$SB_LINEDOWN)
GUICtrlSetData($mylist, "正在处理第"&$i&"个工作表...",1)
$hs = $oExcel1.ActiveSheet.usedrange.rows.count
For $a = 2 To $hs
$1 = _ExcelReadCell($oExcel1, $a, 1)
$2 = _ExcelReadCell($oExcel1, $a, 2)
$3 = _ExcelReadCell($oExcel1, $a, 3)
$4 = _ExcelReadCell($oExcel1, $a, 4)
$5 = _ExcelReadCell($oExcel1, $a, 5)
$6 = _ExcelReadCell($oExcel1, $a, 6)
$7 = $1 + $2 + $3 - $4 + $5 - $6
_ExcelWriteCell($oExcel1,$7,$a,7)
Next
GUICtrlSetData($mylist, "完成"&@CRLF,1)
Next
_ExcelBookSave($oExcel1,0)
_ExcelBookClose($oExcel1,0,0)
MsgBox(0,"提示","已完成所选择工作表的计算")
EndFunc