I want to add an Excel Function to a Cell via C# and Interop (Office 2010).
Let’s take SUM for example.
WorksheetFunction ist NOT what I want, because this is a one time function call.
So what I want is
Xl.Range range = SomeWorksheet.Range["A1"]; range.Formula = "=SUM(A2:A5)";
This is fine if you are using an english version of excel but is an error in every other language.
I found this overview but this would mean to handcode the localization. Not so very nice.
What I need is s.th. like
string localizedFunctionName = Xl.Application.GetFuncName(Func.Sum);
Try the following:
range.FormulaLocal = "=SUM(A2:A5)";
Read more here: http://msdn.microsoft.com/en-us/library/office/aa205983%28v=office.10%29.aspx and this question: VBA: cannot automatically recalculate Excel formula after updating it — needs manual interaction