#include <Excel.au3>
Opt('MustDeclareVars', 1)
Global Const $xlLastCell = 11, $xlExpression = 2
Global $sFileExcel = @ScriptDir & '\1_test.xls', $oObjEr, $oExcel, $sList = 'Тест', $oRange, $iLastColumn, $iLastRow, _
$aBorders[5] = [4, $xlLeft, $xlRight, $xlTop, $xlBottom], $iTimer = TimerInit()
If Not FileExists($sFileExcel) Then Exit @ScriptLineNumber
$oObjEr = ObjEvent('AutoIt.Error', '_Obj_Error')
$oExcel = _ExcelBookOpen($sFileExcel)
If @error Then Exit @ScriptLineNumber - 1
_ExcelSheetActivate($oExcel, $sList)
If @error Then Exit @ScriptLineNumber - 1
$iLastColumn = $oExcel.Cells.SpecialCells($xlLastCell).Column
If Not $iLastColumn Then Exit @ScriptLineNumber - 1
$iLastRow = $oExcel.Cells.SpecialCells($xlLastCell).Row
If Not $iLastRow Then Exit @ScriptLineNumber - 1
$oRange = $oExcel.Range($oExcel.Cells(1, 1), $oExcel.Cells($iLastRow, $iLastColumn - 1))
$oExcel.Columns($iLastColumn).EntireColumn.Hidden = True
$oExcel.Range('A1').Select
Local $aColor[4][2] = [[3],['=$' & Chr(64 + $iLastColumn) & '1="000100"', 3],['=$' & Chr(64 + $iLastColumn) & '1="000300"', 5],['=A1<>""']]
With $oRange
.FormatConditions.Delete
For $j = 1 To $aColor[0][0]
.FormatConditions.Add($xlExpression, 0, $aColor[$j][0])
If $j <> $aColor[0][0] Then .FormatConditions($j).Font.ColorIndex = $aColor[$j][1]
For $i = 1 To $aBorders[0]
.FormatConditions($j).Borders($aBorders[$i]).LineStyle = $xlContinuous
Next
Next
EndWith
;~ _ExcelBookSave($oExcel)
;~ _ExcelBookClose($oExcel)
ConsoleWrite(TimerDiff($iTimer) & @LF)
Func _Obj_Error()
ConsoleWrite('Scriptline :' & $oObjEr.scriptline & @LF)
EndFunc ;==>_Obj_Error