Skip to content

Commit 189adc3

Browse files
committed
Added params parameter Extended Registration example.
1 parent e45101b commit 189adc3

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

docs/guides-basic/dotnet-native-aot-support.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,49 @@ public static string NativeStringArray2D(string[,] s)
385385
| B3 | World |
386386
| C1 | =NativeStringArray2D(A1:B3) | Native StringArray2D VALS: 15 2.36.7 HelloWorld
387387

388+
## params parameter (up to 16 arguments)
389+
390+
```csharp
391+
[ExcelFunction]
392+
public static string NativeParamsFunc1(
393+
[ExcelArgument(Name = "first.Input", Description = "is a useful start")]
394+
object input,
395+
[ExcelArgument(Description = "is another param start")]
396+
string QtherInpEt,
397+
[ExcelArgument(Name = "Value", Description = "gives the Rest")]
398+
params object[] args)
399+
{
400+
return input + "," + QtherInpEt + ", : " + args.Length;
401+
}
402+
403+
[ExcelFunction]
404+
public static string NativeParamsFunc2(
405+
[ExcelArgument(Name = "first.Input", Description = "is a useful start")]
406+
object input,
407+
[ExcelArgument(Name = "second.Input", Description = "is some more stuff")]
408+
string input2,
409+
[ExcelArgument(Description = "is another param ")]
410+
string QtherInpEt,
411+
[ExcelArgument(Name = "Value", Description = "gives the Rest")]
412+
params object[] args)
413+
{
414+
var content = string.Join(",", args.Select(ValueType => ValueType.ToString()));
415+
return input + "," + input2 + "," + QtherInpEt + ", " + $"[{args.Length}: {content}]";
416+
}
417+
418+
[ExcelFunction]
419+
public static string NativeParamsJoinString(string separator, params string[] values)
420+
{
421+
return String.Join(separator, values);
422+
}
423+
```
424+
425+
| Cell | Formula | Result
426+
| ----- | ------------------------------------------| ------
427+
| A1 | =NativeParamsFunc1(1,"2",4,5) | 1,2, : 2
428+
| A2 | =NativeParamsFunc2("a",,"c","d",,"f") | a,,c, [3: d,ExcelDna.Integration.ExcelMissing,f]
429+
| A3 | =NativeParamsJoinString("//","5","4","3") | 5//4//3
430+
388431
# Not supported functionality in native add-ins
389432

390433
Loading images for ribbon controls.

0 commit comments

Comments
 (0)