无法访问JavaScript对象 [英] Can't access Object of JavaScript

查看:104
本文介绍了无法访问JavaScript对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

这是我的代码...

Hi all,

Here is my code...

var a, table1
a = new ActiveXObject("MyProgID");  a.GetDataFromExcel("C:\\Users\\myFolder\\Desktop\\test.xls","Sheet1")
a.Generate()
table1 = a.writeInTable();


在这里,writeInTable函数从用VB.Net编写的DLL返回2D对象数组.所以我把对象放到了table1.
但是从表1中,我无法访问值,但在那里. table1显示的值与该图像一样(已附加图像.)

实际上,我尝试了很多方法,例如
制表符(0)(0)
制表符[0] [0]
tab ["0"]
选项卡.(0).(0)
标签.[0].[0]
同样使用toArray(),(new VBArray(tab)).toArray()....


我不知道我做错了什么.有人可以帮我吗?


谢谢...
Shanmugavel.C


Here writeInTable function returns a 2D Object array from DLL written in VB.Net. So I got the Object to table1.
But from table1, I can''t access the values but its there. table1 shows values as in this image(Image Attached.)

Actually, I tried many ways like
tab(0)(0)
tab[0][0]
tab["0"]
tab.(0).(0)
tab.[0].[0]
Also with toArray(), (new VBArray(tab)).toArray()....


I don''t know what I am wrong..Can anyone help me on this?


Thanks...
Shanmugavel.C

推荐答案

也许这可以帮助您实现目标.

如果您可以从a.writeInTable()返回一个字符串,则可以使用javascript eval()函数 [ ^ ]创建一个二维数组.考虑以下示例:

Perhaps this can help you achieve your goal.

If you can return a string from a.writeInTable() you can use the javascript eval() function [^] to create a 2d array. Consider this example:

<html>
<body>
<script type="text/javascript">

// Make a.writeInTable() return a string like this:
// a.writeInTable() ==> "[['Saab','Volvo','BMW'],['Apple','Orange','Lemon']]"
// var mystring = "mytable=" + a.writeInTable();

var mystring = "mytable=[['Saab','Volvo','BMW'],['Apple','Orange','Lemon']]";

// create the 2d array 'mytable'
eval(mystring);

// walk through the array
for (i=0;i<mytable.length;i++)>
{
  for (j=0;j<mytable[i].length;j++)>
  {
    document.write(i+ ',' + j + ': ' + mytable[i][j] + "<br />");
  }
}

</script>
</body>
</html>



这将显示以下结果:



This will show the following result:

0,0: Saab<br />
0,1: Volvo<br />
0,2: BMW<br />
1,0: Apple<br />
1,1: Orange<br />
1,2: Lemon



有关2d数组的更多信息,请查看以下线程:
http://www.webdeveloper.com/forum/showthread.php?t=90849 [ ^ ]



For more information on 2d arrays take a look at this thread:
http://www.webdeveloper.com/forum/showthread.php?t=90849[^]


您的代码可能有两个问题.
首先,ActiveXObject类不采用prostd实例,而是采用ActiveX控件名称.
其次,activex对象可能未在您的系统中注册.

尝试解决这些问题,您的代码可能会开始工作.
There might be two problems with your code.
First, ActiveXObject class does not takes progid instde is takes the ActiveX control name.
Second, The activex object might not be register in your system.

Try to address these problem your code might start working.


对不起..
实际上,我的DLL已成功注册并能够创建实例.其他功能也在起作用.
即使此功能正常工作,但在这里我的问题是要返回哪种数据类型,以便可以在目标脚本中使用它?

对象或数组以及如何在我的脚本中访问该对象或数组?

谢谢,
Shanmugavel.C
Sorry..
Actully my DLL got registered successfully and able to create instance. Also other functions are working.
Even this function is working but here my problem is what data type to return so that i can use it in my target scripting?

Object or array and how to access that one in my scripting?

Thanks,
Shanmugavel.C


这篇关于无法访问JavaScript对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆