We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Add ConditionalFormats

Hello,

I try to add conditional formats to a cell. But when I run the code sheet[x,y].ConditionalFormats.AddCondition() I get the ArgumentOutOfRangeError 'Too many conditional formats'.

I tried to add the conditional formats in the excel template directly, but only 3 conditional formats remain in my excel template, the 4th one has disappeared in the excel file (while it is in the template)

1 Reply

LR Lokesh R Syncfusion Team January 12, 2010 10:36 AM UTC

Hi Marcia,

Thank you for your interest on Syncfusion products.


Excel allows the addition of a maximum of three conditions only, for the same cell in the Biff8 format(Excel 2003 format).

XlsIO allows to create conditional formats using IConditionFormats, and various conditions can be set using its properties. It also provides support for applying more than three conditional formats in the same cell, in the .xlsx (Excel 2007)format,which is a constraint in Excel2003 format as i have mentioned earlier(allows only 3 conditions to be applied).

Could you please make the below changes in your code.so,that it would work as you expected.


IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2007;
IWorkbook workbook = application.Workbooks.Create(1);

and save the file in XLSX format as below:

workbook.SaveAs("Sample.xlsx");
workbook.Close();
excelEngine.Dispose();


For more information about conditionalformatting,please visit

http://www.syncfusion.com:91/products/xlsio/backoffice/Articles/conditional_formatting.aspx.


please let me know if this helps.

Regards,
Lokesh

Loader.
Live Chat Icon For mobile
Up arrow icon