Question

I'm using the Ignite UI toolset to generate Excel spreadsheets. I have some code that was working in an old version of my app (I pulled the source from old SVN code), but now I'm getting a really bizarre issue.

The exception I get is:

An exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' 
occurred in Unknown Module. but was not handled in user code

Additional information: 'object' does not contain a definition for 'Fill'

If there is a handler for this exception, the program may be safely continued.

Here's a screenshot of the debugger that shows that cell.CellFormat.Fill (which I'm trying to set and get the exception on) is showing up in the watch window. Notice that cell itself is a dynamic object.

Screenshot of debugger

Anyone have any idea what might be causing this? Maybe I just haven't dealt with dynamic objects enough, but it sure seems to me that "Fill" is there.

Was it helpful?

Solution

I had my question answered by Infragistics, but offer the solution in case others come across it as well.

The solution was simply to cast the cells as WorksheetCell instead of using var in the foreach loop, so:

foreach (WorksheetCell cell in region)
{
    cell.CellFormat.Fill = CellFill.CreateSolidFill(System.Drawing.Color.Gray);
    cell.CellFormat.Font.ColorInfo = new WorkbookColorInfo(System.Drawing.Color.White);
}

I'm not entirely sure why that fixes it, so I plan on digging into that at some point and may update this answer with that info when I have it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top