I'm creating a plugin for excel, i would like to know how is it possible to create new rows to display a list or array
I created a sample function :
[ExcelFunction(Description = "Split string", Category = "STRING")]
public static object[] StringSplit([ExcelArgument(Name = "TEXT", Description = "text to split")] string text)
{
return text.Split(' ').ToArray();
}
In this example, the function returns an array with the different keywords. but when i use it via excel, it displays only the first word in my cell. what i want to know is to create news columns or rows and display each element of my array in it. thanks
Edit I tried the solution posted by @CaioProiete bellow, so it works fine with this code :
Page page = new Page();
WebResponse resp = page.Download(url);
List<string> res = page.GetAllFromXpath(resp.content, xpath);
object[,] result = new object[1, res.Count];
for (int j = 0; j < res.Count; j++)
{
result[0, j] = res.ElementAt(j);
}
return Resizer.Resize(result);
but when i try the asyncrohous method, this throw an exeption not handled :
return ExcelAsyncUtil.Run("DownloadAsync", url,
delegate
{
Page page = new Page();
WebResponse resp = page.Download(url);
List<string> res = page.GetAllFromXpath(resp.content, xpath);
object[,] result = new object[1, res.Count];
for (int j = 0; j < res.Count; j++)
{
result[0, j] = res.ElementAt(j);
}
return Resizer.ResizeMe(result);
});
the exception thrown is :
ExcelDna.Integration.XlCallException' occurred in ExcelDna.Integration.dll but was not handled in user code
And here is the line in the Reizer class that throw it:
ExcelReference caller = XlCall.Excel(XlCall.xlfCaller) as ExcelReference;