IStyle style = XLBook.IWorkbook.Styles.Add(XLAssistant.TitleStyle);
style.BeginUpdate(); style.IncludeNumberFormat = false; style.IncludeFont = true; style.IncludeAlignment = true; style.IncludeBorder = false; style.IncludePatterns = false; style.IncludeProtection = false; style.Font.Size = 20; style.Font.Bold = true; style.Font.Italic = true; style.EndUpdate(); style = XLBook.IWorkbook.Styles.Add(XLAssistant.HeadingStyle); style.BeginUpdate(); style.IncludeNumberFormat = false; style.IncludeFont = true; style.IncludeAlignment = true; style.IncludeBorder = false; style.IncludePatterns = true; style.IncludeProtection = false; style.Interior.ColorIndex = ExcelKnownColors.Custom9; style.Interior.FillPattern = ExcelPattern.Solid; style.Font.Italic = true; style.Font.Bold = true; style.Font.Color = ExcelKnownColors.Custom1; style.HorizontalAlignment = ExcelHAlign.HAlignCenter; style.VerticalAlignment = ExcelVAlign.VAlignBottom; style.WrapText = true; style.EndUpdate();
...
IRange range = worksheet.Range[2, 1];
// Works
range.CellStyleName = XLAssistant.TitleStyle;
// Throws ArgumentOutOfRangeException
range.CellStyleName = XLAssistant.HeadingStyle;
I am using Syncfusion.XlsIO.Base version 12.4400.0.24 for .NET v4.0.30319.
Thanks for your help,
Jonny
Hi Jonny,
Thank you using Syncfusion products.
Regarding Interior query:
We recommend you to use IStyle.ColorIndex instead of Interior.ColorIndex and IStyle.FillPattern instead of Interior.FillPattern. Could please share us the scenario in which you’re using the Interior property so that we can provide a prompt solution or any other alternative way to achieve it.
Regarding CellStyleName query:
CellStyleName value is a case-sentitive. This is not a bug
Regards,
Dilli babu.
Hi Jonny,
Thank you for updating us.
You can use Style.FillPattern and Style.ColorIndex which meets the requirement. Please let us know if you need any further assistance.
Regards,
Dilli babu.