Welcome to the WinForms feedback portal. We’re happy you’re here! If you have feedback on how to improve the WinForms, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
I have a spreadsheet I am building using XLSIO 22.1.38. I am interfacing with a Win32 application so it is convenient to use the integer color numbers that FromWin32() provides.
The bug only shows up in a very specific situation... here's how to duplicate
I have an entire row that has a color assigned using:
this.worksheet.Range["A1"].EntireRow.CellStyle.Color = ColorTranslator.FromWin32(value)
Next, set a single cell color:
this.worksheet.Range["A3"].CellStyle.Color = ColorTranslator.FromWin32(value)
Now, when I try to retrieve the row color using this code, I get 0
return ColorTranslator.ToWin32(this.worksheet.Range["A3"].EntireRow.CellStyle.Color)
I am using "A3" here as a cell, which shouldn't matter since the EntireRow is what I'm after anyway (EDIT: Made a mistake here, see below, I probably should have said "B1")
Using the debugger, when I hover over EntireRow, it contains a CellStyle that is correct, with a Color attribute that is correct, but when chained like this, it fails. Hover over CellStyle and it is an empty object.
This code actually works correctly:
var row = this.worksheet.Range["A3"].EntireRow;
var _ = row.CellStyle.Color; // must be assigned to a variable, BUT DO NOT USE IT, as it is invalid
return ColorTranslator.ToWin32(row.CellStyle.Color); // This is correct