I'm working with SpreadStreamProcessing. I want to set the background color for each of the cells in a specific row.
Created an excel mockup and like the "Blue, Accent 5, Lighter 40%". How can I find the RGB code for this?
Also is there somewhere one can find a color converter to RGB or visa versa?
5 Answers, 1 is accepted
Hello Herb,
I am aware that you are using SpreadStreamProcessing. However, I cannot suggest a solution to it and this is why I have logged a feature request for this. Please note that the color is not stored in the file as an RGB value. The suggestion in my previous post gets the color from the theme and each theme is stored in our library. The themes are not stored in the file as well.
Let me know if I can assist you further.
Regards,
Dimitar
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hello Herb,
Is this a custom or a predefined style? If it is a predefined style you can get it from styles collection by name. For example:
var style1 = workbook.CellStyles.GetByName("20% - Accent6");
You can view all available style names with the following code:
foreach (var item in workbook.CellStyles) { Console.WriteLine(item.Name); }
If your template document contains custom styles, you need to manually create them and add them to the styles collection:
SpreadCellStyle style = workbook.CellStyles.Add("MyStyle");
style.Underline = SpreadUnderlineType.DoubleAccounting;
style.VerticalAlignment = SpreadVerticalAlignment.Top;
Then you can use the style with the following code:
cell.SetFormat(new SpreadCellFormat()
{
CellStyle = style1,
HorizontalAlignment = SpreadHorizontalAlignment.Center,
VerticalAlignment = SpreadVerticalAlignment.Center
});
I hope this helps. Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Herb,
I forgot to mention that there is one more way to set this color manually. For example, you can use the following code to set the fill:
var color = new SpreadThemableColor(SpreadThemeColorType.Accent5, SpreadColorShadeType.Shade3);
cell.SetFormat(new SpreadCellFormat()
{
//CellStyle = style1,
Fill = SpreadPatternFill.CreateSolidFill(color),
HorizontalAlignment = SpreadHorizontalAlignment.Center,
VerticalAlignment = SpreadVerticalAlignment.Center
});
Let me know if I can assist you further.
Regards,
Dimitar
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Herb,
I have further investigated this and currently, it is not possible to get the color. The color comes from the theme and is not stored in the style. I have logged a feature request that will allow you to achieve this with our API. You can track its progress, subscribe to status changes, and add your comment to it here. I have updated your Telerik points as well.
Let me know if I can assist you further.
Regards,
Dimitar
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi Herb,
There is a way with the SpreadProcessing (not SpreadStreamProcessing) if this is suitable for you. For example, you can use the following approaches to get the color from the default theme (or other themes by specifying the name):
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Workbook workbook = new Workbook();
ThemableColor themableColor = new ThemableColor(ThemeColorType.Accent5, ColorShadeType.Shade3);
Color actualColor = themableColor.GetActualValue(workbook.Theme);
var schemes = PredefinedThemeSchemes.ColorSchemes;
var colorScheme = schemes.Where(x => x.Name == "Office").FirstOrDefault();
ThemeFontScheme fontScheme = new ThemeFontScheme(
"Mine",
"Times New Roman", // latinMajor
"Arial"); // latinMinor
var theme = new DocumentTheme("custom", colorScheme, fontScheme);
Color actualColor2 = themableColor.GetActualValue(theme);
}
Let me know if I can assist you further.
Regards,
Dimitar
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.