Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript导出excel时合并列?_Javascript_Export To Excel - Fatal编程技术网

使用javascript导出excel时合并列?

使用javascript导出excel时合并列?,javascript,export-to-excel,Javascript,Export To Excel,我可以导出excel,但问题是无法合并excel标题列。我已经附上了一个图像,你可以检查。这就是我想出口的东西 我想在excel中导出此表。 <table id="" class="uk-report-table table table-striped"> <thead> <tr>

我可以导出excel,但问题是无法合并excel标题列。我已经附上了一个图像,你可以检查。这就是我想出口的东西

我想在excel中导出此表。

                    <table id="" class="uk-report-table table table-striped">
                        <thead>
                            <tr>
                                <th colspan="1">Date Range</th>
                                <th colspan="5">
                                    <h2>Last 30 Days</h2>
                                </th>
                                <th colspan="5">
                                    <h2>Previous 30 Days</h2>
                                </th>
                            </tr>
                            <tr>
                                <th>A</th>
                                <th>B</th>
                                <th>C</th>
                                <th>D</th>
                                <th>E</th>
                                <th>A2</th>
                                <th>B2</th>
                                <th>C2</th>
                                <th>D2</th>
                                <th>E2</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>


我建议使用基于javascript的excel库(例如)生成一个真正的excel文件。与通过csv或html文件假冒mime类型相比,您将有更多的选择,这就是示例代码所做的

这是一个例子


函数exportFile(){
var wb=XLSX.utils.table_to_book(document.getElementById('sampletable');
writeFile(wb,'sample.XLSX');
返回false;
}
日期范围
过去30天
前30天
A.
B
C
D
E
A2
地下二层
C2
D2
E2
出口

我没有找到任何解决方案,因此该问题被问到。你会推荐任何现有的解决方案吗?你会分享你的详细代码描述吗?我剪切了我的表格格式。我要将此表导出到excel。我附上了一张我想导出的示例照片。您可以使用javascript为我推荐任何解决方案。非常感谢。是的,真的很管用。也许它是最受欢迎的可靠软件包,对吧?它的下载量超过50万--。所以我得说它很受欢迎。
<html>
<head>
<script src="//unpkg.com/xlsx/dist/xlsx.full.min.js" type="text/javascript"></script>
<script>
function exportFile(){
  var wb = XLSX.utils.table_to_book(document.getElementById('sampletable'));
  XLSX.writeFile(wb, 'sample.xlsx');
  return false;
}
</script>
</head>
<body>
<table id="sampletable" class="uk-report-table table table-striped">
                        <thead>
                            <tr>
                                <th colspan="1">Date Range</th>
                                <th colspan="5">
                                    <h2>Last 30 Days</h2>
                                </th>
                                <th colspan="5">
                                    <h2>Previous 30 Days</h2>
                                </th>
                            </tr>
                            <tr>
                                <th>A</th>
                                <th>B</th>
                                <th>C</th>
                                <th>D</th>
                                <th>E</th>
                                <th>A2</th>
                                <th>B2</th>
                                <th>C2</th>
                                <th>D2</th>
                                <th>E2</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
<button onclick="return exportFile()">Export</button>
</body>
</html>