SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>demo</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.2/xlsx.min.js"></script>
</head>

<body>
    <table id="table1">
        <thead>
            <tr>
                <th scope="col">序号</th>
                <th scope="col">省份</th>
                <th scope="col">城市</th>
                <th scope="col">邮编</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th scope="row">1</th>
                <td>四川</td>
                <td>成都</td>
                <td>61000</td>
            </tr>
        </tbody>
    </table>
    <button onclick="outport()">导出</button>
    <script>
        function outport() {
           
            var filename = "按省份统计.xls";
            var workbook = XLSX.utils.book_new();
            var ws1 = XLSX.utils.table_to_sheet(document.getElementById('table1'));
            XLSX.utils.book_append_sheet(workbook, ws1, "Sheet1");
            XLSX.writeFile(workbook, filename); //导出Excel
        }
    </script>


</body>

</html>