>lcLastCell = oExcel.ActiveCell.SpecialCells(xlLastCell).Address()
>oExcel.Range("B9:" + lcLastCell).Select
>
>oExcel.Selection.FormatConditions.Delete
> oExcel.Selection.FormatConditions.Add(xlExpression,1,"=RIGHT($B9,5)='Total'")
>
>
lcXLS = Sys(5)+Curdir()+'Conditional.xls' Select cust_id, Company, Contact, Title, maxordamt ; from customer ; into Cursor crsCustomer Copy To (lcXLS) Type Xl5 #Define xlCellValue 1 #Define xlExpression 2 #Define xlBetween 1 #Define xlNotBetween 2 #Define xlEqual 3 #Define xlNotEqual 4 #Define xlGreater 5 #Define xlLess 6 #Define xlGreaterEqual 7 #Define xlLessEqual 8 lnRows = Reccount() lnCols = Fcount() Use In 'crsCustomer' Use In 'customer' oExcel = Createobject('Excel.Application') With oExcel .WorkBooks.Open(lcXLS) .ActiveWorkbook.ActiveSheet.UsedRange.Columns.Autofit *ValueSample() ExpressionSample() .Visible = .T. Endwith Function ValueSample lcRange = _GetChar(lnCols)+'2:'+; _GetChar(lnCols)+Ltrim(Str(lnRows+1)) && 1 header With oExcel.ActiveWorkbook.ActiveSheet.Range(lcRange) .FormatConditions.Delete .FormatConditions.Add(xlCellValue, xlLess, "2000" ) .FormatConditions.Add(xlCellValue, xlBetween, "2000", "4000" ) With .FormatConditions(1) .Interior.ColorIndex = 4 Endwith .FormatConditions(2).Interior.ColorIndex = 3 Endwith Function ExpressionSample lcRange = 'A2:'+_GetChar(lnCols)+Ltrim(Str(lnRows+1)) && 1 header oExcel.ActiveWorkbook.ActiveSheet.Range('A2').Activate With oExcel.ActiveWorkbook.ActiveSheet.Range(lcRange) .FormatConditions.Delete .FormatConditions.Add(xlExpression,, '=Left($D2,5)="Sales"') With .FormatConditions(1) .Font.Bold = .T. .Interior.ColorIndex = 4 Endwith Endwith * Return A, AA, BC etc noation for nth column Function _GetChar Lparameters tnColumn && Convert tnvalue to Excel alpha notation If tnColumn = 0 Return "" Endif If tnColumn <= 26 Return Chr(Asc("A")-1+tnColumn) Else Return _GetChar(Int(Iif(tnColumn % 26 = 0,tnColumn - 1, tnColumn) / 26)) + ; _GetChar((tnColumn-1)%26+1) EndifCetin