当尝试在VBA中调用以下Excel-DNA-Method时,我只得到一个大小为1的数组(在65536行之后,该数组的大小似乎被调整为实际的数组大小- 65537)。当将表中的方法作为数组函数调用时,整个过程都会正常工作。
[ExcelFunction(Description = "Example", Name = "Example", HelpTopic = "")]
public static object[] example() {
object[] ret = new object[65537];
return ret;
}我正在使用Excel2007,工作表是一个xlsm-Worksheet,当使用像这样的二维数组时,一切都很好。
[ExcelFunction(Description = "Example", Name = "Example", HelpTopic = "")]
public static object[,] example() {
object[,] ret = new object[65537,1];
return ret;
}但是使用二维数组的方式与发生这种情况的情况相同。
[ExcelFunction(Description = "Example", Name = "Example", HelpTopic = "")]
public static object[,] example() {
object[,] ret = new object[1,65537];
return ret;
}有没有人知道如何解决这个问题?
在VBA中做同样的事情也没问题
Function test()
Dim ret As Variant
ReDim ret(65536)
test = ret
End Function
Sub testSub()
Dim output
output = Application.Run("test")
End Sub输出的维度为65537 (索引从0开始),也是大于65537个工作的数字。
发布于 2013-02-16 22:38:29
假设您使用二维数组和反转维度表示了不同的性能,这听起来像是您遇到了行和/或列的限制。
本页:http://office.microsoft.com/en-us/excel-help/excel-specifications-and-limits-HP010073849.aspx给出了Excel2007的限制。正如您将看到的,工作表中的列数被限制为16,384列,您的值超过了这个值的许多倍。另一方面,1,048,576的行限制可以轻松地容纳65537的值。
我的猜测是,当您请求具有65537列的对象时,构造函数将静默地处理溢出并将其解析为1。
https://stackoverflow.com/questions/14258507
复制相似问题