Доброе время суток! Задача такова, надо вычислить в таблице Excel сколько красных ячеек, сколько зеленных ячеек, так и далее... с помощью C++ Builder.
1 ответ
Затрудняюсь сказать, как узнать цвет ячейки прямо из C++ Builder. Вы можете создать макросы VBA и уже их как-нибудь использовать из приложения C++ Builder. Пример макроса:
Function ColorIndexOfOneCell(Cell As Range, OfText As Boolean, _
DefaultColorIndex As Long) As Long
Dim CI As Long
Application.Volatile True
If OfText = True Then
CI = Cell(1, 1).Font.ColorIndex
Else
CI = Cell(1, 1).Interior.ColorIndex
End If
If CI < 0 Then
If IsValidColorIndex(ColorIndex:=DefaultColorIndex) = True Then
CI = DefaultColorIndex
Else
CI = -1
End If
End If
ColorIndexOfOneCell = CI
End Function
Private Function IsValidColorIndex(ColorIndex As Long) As Boolean
Select Case ColorIndex
Case 1 To 56
IsValidColorIndex = True
Case xlColorIndexAutomatic, xlColorIndexNone
IsValidColorIndex = True
Case Else
IsValidColorIndex = False
End Select
End Function
Взято отсюда: Color Functions In Excel.