When trying to call the following Excel-DNA-Method in VBA I only get an array of size 1 (after 65536 rows the array seems to be resized to real array size - 65537). When calling the method in the sheet as array function the whole thing works.
[ExcelFunction(Description = "Example", Name = "Example", HelpTopic = "")]
public static object[] example() {
object[] ret = new object[65537];
return ret;
}
I am working with Excel 2007, the sheet is a xlsm-Worksheet, when using two-dimensional arrays like this, everything works fine.
[ExcelFunction(Description = "Example", Name = "Example", HelpTopic = "")]
public static object[,] example() {
object[,] ret = new object[65537,1];
return ret;
}
But using the two-dimension arrays the other way round the same as in case one happens
[ExcelFunction(Description = "Example", Name = "Example", HelpTopic = "")]
public static object[,] example() {
object[,] ret = new object[1,65537];
return ret;
}
Does someone have an idea how to get around this?
Doing the same thing in VBA works fine
Function test()
Dim ret As Variant
ReDim ret(65536)
test = ret
End Function
Sub testSub()
Dim output
output = Application.Run("test")
End Sub
output has a dimension of 65537 (indexing starts with 0), also numbers greater than 65537 work.
object[]
instead ofobject[,]
in the first example? – Bell1.
return one dimensional array indexing from 0 to 1 or2.
return two dimensional array indexing from 0 to 1, 0 to 65537? – Ginn