帮助我试图学习如何使用JavaScript阅读excell文件 [英] HELP im trying to learn how to read an excell file using javascript

查看:69
本文介绍了帮助我试图学习如何使用JavaScript阅读excell文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了以下代码,但是当我运行它时只显示一个空白屏幕。



我尝试过:









函数readData(x,y)

{

var excel = new ActiveXObject(Excel.Application);

var book = excel.Workbooks.Open(c:\mydocuments\ TSP& amp; CCA-Release Management \ 012918 ACH更改控制详细报告导出为Chris)。text()+'。xls');

var sheet = excel_file.Worksheets(预定发布);

var data = excel_sheet.cells(x,y).value; // x,y考虑行和列的坐标或数据

返回数据;



}











var value = readData(1,1) ; //这应该读取单元格A1



document.write(Excel文件中的值是+值);

I have written the following code but when I run it just displays a blank screen.

What I have tried:




function readData(x,y)
{
var excel=new ActiveXObject("Excel.Application");
var book=excel.Workbooks.Open("c:\mydocuments\TSP&CCA-Release Management\012918 ACH Change Control Detail Report exported for Chris").text()+'.xls');
var sheet=excel_file.Worksheets("Scheduled Releases");
var data = excel_sheet.cells(x,y).value; //x,y consider the coordinate of row and column or the data
return data;

}





var value = readData(1,1); //this should read cell A1

document.write("Value from Excel file is " + value);

推荐答案

该代码仅在用户安装了Excel,手动修改其注册表以允许其从js自动化并且使用仍支持ActiveX的浏览器时才有效。你有更好的机会在月球上行走,让代码正常工作。



如果你谷歌你可以找到替代解决方案,如果是xslx文件,那么工作就是因为xml比Excel的专有二进制格式更容易解析,所以稍微容易一点。



json - 如何解析Javascript / HTML5中的Excel文件 - Stack Overflow [ ^ ]
That code will only work if the user has Excel installed, has manually amended their registry to allow it to be automated from js, and is using a browser that still supports ActiveX. You have a better chance of walking on the moon that getting that code working.

If you google you can find alternative solutions, if it is an xslx file the job is slightly easier as xml is easier to parse than the proprietary binary format of Excel.

json - How to parse Excel file in Javascript/HTML5 - Stack Overflow[^]


这篇关于帮助我试图学习如何使用JavaScript阅读excell文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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