unvell / ReoGrid

Fast and powerful .NET spreadsheet component, support data format, freeze, outline, formula calculation, chart, script execution and etc. Compatible with Excel 2007 (.xlsx) format and working on .NET 3.5 (or client profile), WPF and Android platform.
https://reogrid.net
MIT License
1.32k stars 390 forks source link

Question about defined functions that return a solution matrix #153

Open salvo79 opened 6 years ago

salvo79 commented 6 years ago

Hi Someone has worked with defined functions that return an objects [,] to the grid. In other words, using NativeFunctionObject with a 2D solution instead of a single solution. My code

this.grid.Srm["ORION_5G"] = new NativeFunctionObject("ORION_5G", (ctx, owner, args) =>
            {  var result= ORION_CC.ORION5G(args[0].ToString(), args[1], args[2]);
               return (args.Length < 1) ? null : (result);});
        }

The expected solution is a object[,] 2d matrix Regards

jingwood commented 6 years ago

Returning a rectangular multiple dimensional array is possible, but the array cannot be set onto worksheet automatically. Since formula does only effect to single cell.

Best practice maybe is to set data directly onto worksheet inside the function instead of returning an array.

jingwood commented 3 years ago

@salvo79 How about this now?