将html表保存到excel中 [英] Save html table into excel

查看:125
本文介绍了将html表保存到excel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个程序,定期读取网页并将该页面上的表格中的某些数据复制到Excel电子表格中。我不知道从哪里开始或者什么编程语言适合这个项目。我知道一点C ++和Matlab编程。任何人都可以提供建议,指出我正确的方向或建议做类似的开源项目吗?

I must write a program that periodically reads a web page and copies certain data from a table on that page to an Excel spreadsheet. I don't know where to start or what programming language is suitable for this project. I know a little C++ and Matlab programming. Can anyone offer advice to point me in the right direction or suggest open source projects which do something similar?

推荐答案

也许这会工作..

<html>
<head>
<script type="text/javascript">
    function CreateExcelSheet() {
        var x = myTable.rows;

        var xls = new ActiveXObject("Excel.Application");
            xls.visible = true;
            xls.Workbooks.Add;
        for (i = 0; i < x.length; i++) {
            var y = x[i].cells;
            for (j = 0; j < y.length; j++) {
                xls.Cells( i+1, j+1).Value = y[j].innerText;
            }
        }
    }
</script>
</head>
<body>

<form>
    <input type="button" onclick="CreateExcelSheet()" value="Create Excel Sheet">
</form>

<table id="myTable" border="1">
    <tr>
        <td>Name</td>
        <td>Age</td>
    </tr>
    <tr>
        <td>Shivani</td>
        <td>25</td>
    </tr>
    <tr>
        <td>Naren </td>
        <td>28</td>
    </tr>
    <tr>
        <td>Logs</td>
        <td>57</td>
    </tr>
    <tr>
        <td>Kas</td>
        <td>54</td>
    </tr>
    <tr>
        <td>Sent</td>
        <td>26</td>
    </tr>
    <tr>
        <td>Bruce</td>
        <td>7</td>
    </tr>
</table>

</body>
</html>

这篇关于将html表保存到excel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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