//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; //Range A1's displaying color is table style worksheet.Tables.Add(worksheet.Range["A1:E5"], true); var color_A1 = worksheet.Range["A1"].DisplayFormat.Interior.Color; //Range A1's displaying color will be cell style, yellow. worksheet.Range["A1"].Interior.Color = Color.Yellow; var color_A1_1 = worksheet.Range["A1"].DisplayFormat.Interior.Color; //Range A1's displaying color will be conditional format style, green. IFormatCondition condition = worksheet.Range["A1"].FormatConditions.Add(FormatConditionType.NoBlanksCondition) as IFormatCondition; condition.Interior.Color = Color.Green; var color_A1_2 = worksheet.Range["A1"].DisplayFormat.Interior.Color; // Save to an excel file workbook.Save("GetDisplayFormat.xlsx");
' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) 'Range A1's displaying color is table style worksheet.Tables.Add(worksheet.Range("A1:E5"), True) Dim color_A1 = worksheet.Range!A1.DisplayFormat.Interior.Color 'Range A1's displaying color will be cell style, yellow. worksheet.Range!A1.Interior.Color = Color.Yellow Dim color_A1_1 = worksheet.Range!A1.DisplayFormat.Interior.Color 'Range A1's displaying color will be conditional format style, green. Dim condition As IFormatCondition = TryCast(worksheet.Range!A1.FormatConditions.Add(FormatConditionType.NoBlanksCondition), IFormatCondition) condition.Interior.Color = Color.Green Dim color_A1_2 = worksheet.Range!A1.DisplayFormat.Interior.Color ' save to an excel file workbook.Save("GetDisplayFormat.xlsx")