I'm working in C# with EPPlus v 4.1 and not having luck applying a formula to a non-contiguous block of cells.
I'm able to use the following code to apply a formula to a range of selected cells that are contiguous.
Worksheet.Select(new ExcelAddress("T2:T10"));
Worksheet.SelectedRange.Formula = "=if(A2=\"\",\"empty\",\"not empty\")";
This works great because it changes the formula so that for cell T2 the cell that is checked is A2, and for cell T3 the cell that is checked is A3, etc.
However, when I have a non-contiguous block of cells, the application of the formula appears to fail, and only the first cell in the selected range receives the formula. The following code results in just cell T2 receiving the formula.
Worksheet.Select(new ExcelAddress("T2,T5,T8,T10"));
Worksheet.SelectedRange.Formula = "=if(A2=\"\",\"empty\",\"not empty\")";
The same is true when I use the Cells property.
// awesome
Worksheet.Cells["T2:T10"].Formula = "=if(A2=\"\",\"empty\",\"not empty\")";
// not so awesome
Worksheet.Cells["T2,T5,T8,T10"].Formula = "=if(A2=\"\",\"empty\",\"not empty\")";
Does this sound like a bug (known or unknown), or is this more of an error on my part?
I've also posted this on the codeplex site last week, but that appears to be going away.
Thanks!