conditional formatting excel
Posted: Mon Feb 05, 2018 10:44 am
Hi,
Is there a way to add conditional formatting to a cell in excel via FWH?
Is there a way to add conditional formatting to a cell in excel via FWH?
www.FiveTechSoft.com
https://fivetechsoft.com/forums/
Code: Select all
oSheet:Cells( nL, 4 ):Interior:ColorIndex := if( hora->HSAI < "04:00", Verde, Vermelho )
oSheet:Cells( nL, 5 ):value := hora->H1PV
oSheet:Cells( nL, 6 ):value := hora->HUPV
oSheet:Cells( nL, 6 ):Interior:ColorIndex := if( hora->HUPV < "06:31", Verde, Vermelho )
oSheet:Cells( nL, 7 ):value := if( "=F" + allTrim( str( nL ) ) > "E" + allTrim( str( nL ) ), "=F" + allTrim( str( nL ) ) + "-E" + allTrim( str( nL ) ), "=F" + allTrim( str( nL ) ) + "-E" + allTrim( str( nL ) ) + "+24" )// "=F" + allTrim( str( nL ) ) + "-E" + allTrim( str( nL ) )
oSheet:Cells( nL, 8 ):value := if( "=F" + allTrim( str( nL ) ) > "D" + allTrim( str( nL ) ), "=F" + allTrim( str( nL ) ) + "-D" + allTrim( str( nL ) ), "=F" + allTrim( str( nL ) ) + "-D" + allTrim( str( nL ) ) + "+24" ) //"=F" + allTrim( str( nL ) ) + "-D" + allTrim( str( nL ) )
Code: Select all
oExcel := CreateObject( "Excel.Application" )
oExcel:WorkBooks:Add()
oAs := oExcel:Activesheet()
oAs:Cells:Font:Name := "Calibri"
oAs:Cells:Font:Size := 11
oAs:Columns( 1 ):ColumnWidth := 17
oAs:Columns( 2 ):ColumnWidth := 150
oAs:Cells( 3, 1 ):Value := "Prog"
oAs:Cells( 3, 2 ):Value := "Note"
n = 1
for n = 1 to 2
oAs:Cells(3,n):Borders(7):LineStyle := 1
oAs:Cells(3,n):Borders(8):LineStyle := 1
next
Use archivio
go top
n = 4
do while !eof()
sysrefresh()
oAs:Cells( n, 1 ):Value := archivio->c1) // prog
oAs:Cells( n, 2 ):Value := archivio->c2) // campo note
n = n+1
skip
enddo
n1 = 1
for n1 = 1 to 2
oAs:Cells(n-1,n1):Borders(9):LineStyle := 1
next
oAs:Columns( "A:B" ):WrapText = .T.
/*
oAs:Name := "NC"
* oAs:Columns( "A:T" ):AutoFit()
oAs:Columns( "A:Z" ):VerticalAlignment := -4108
oAs:Columns( "A:Z" ):HorizontalAlignment := -4108
oAs:Columns( "C:C" ):HorizontalAlignment := -4131
oAs:Columns( "Q:Q" ):HorizontalAlignment := -4131
oAs:Columns( "W:W" ):WrapText = .F.
oAs:Range("I2:Q2"):interior:color := rgb(184,204,228)
oAs:Range("I3:Q3"):interior:color := rgb(217,217,217)
oAs:Range("A3:H3"):interior:color := rgb(54,96,146)
oAs:Range("A3:H3"):font:color := rgb(255,255,255)
*/
oExcel:visible := .T
Code: Select all
oRng := oSheet:Range( oSheet:Cells( 1, 1 ), oSheet:Cells( 1, 7 ) )
oCond1 := oRng:FormatConditions:Add(xlCellValue, xlGreater, "=80")
oCond2 := oRng:FormatConditions:Add(xlCellValue, xlLess, "=50")
WITH OBJECT oCond1
:Font:Bold := .T.
:Font:Color = azul
END
WITH OBJECT oCond2
:Font:Bold := .T.
:Font:Color = vermelho
END
ADutheil wrote:I'd try something like this:NOT TESTEDCode: Select all
oRng := oSheet:Range( oSheet:Cells( 1, 1 ), oSheet:Cells( 1, 7 ) ) oCond1 := oRng:FormatConditions:Add(xlCellValue, xlGreater, "=80") oCond2 := oRng:FormatConditions:Add(xlCellValue, xlLess, "=50") WITH OBJECT oCond1 :Font:Bold := .T. :Font:Color = azul END WITH OBJECT oCond2 :Font:Bold := .T. :Font:Color = vermelho END
Code: Select all
oCond1 := oRng:FormatConditions:Add(xlCellValue, xlEqual, "Tekst")
Code: Select all
oCond1 := oRng:FormatConditions:Add(xlCellValue, xlEqual, "$B$2")