Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.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/0/laravel/10.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 使用制表器下载多个html表格时遇到问题吗?_Javascript_Laravel_Tabulator - Fatal编程技术网

Javascript 使用制表器下载多个html表格时遇到问题吗?

Javascript 使用制表器下载多个html表格时遇到问题吗?,javascript,laravel,tabulator,Javascript,Laravel,Tabulator,我可以用tablator在一个页面上呈现两个表。现在我需要将两个表导出到一个excel工作簿(不同的工作表) 我尝试过文档中提供的示例,但没有成功 头部标签中包含的脚本 {{-- tabulator links --}} <link rel="stylesheet" href="css/tabulator/tabulator_simple.css" rel="stylesheet"> <link rel="stylesheet" href="css/tabulator/tabu

我可以用tablator在一个页面上呈现两个表。现在我需要将两个表导出到一个excel工作簿(不同的工作表)

我尝试过文档中提供的示例,但没有成功

头部标签中包含的脚本

{{-- tabulator links --}}
<link rel="stylesheet" href="css/tabulator/tabulator_simple.css" rel="stylesheet">
<link rel="stylesheet" href="css/tabulator/tabulator_custom.css" rel="stylesheet">
<script src="js/tabulator/tabulator.min.js"></script>

{{-- XLSX Script Includes --}}
<script type="text/javascript" src="http://oss.sheetjs.com/js-xlsx/xlsx.full.min.js"></script>

//define data
    var one = {!!$one!!}

    //define table
    var table = new Tabulator("#tableOne", {
        data:one,
        autoColumns:true,
        height:"500px",
        layout:"fitDataFill",
        selectable:true,
        clipboard:true,
    });

    //define data
    var two = {!!$two!!}

    //define table
    var table = new Tabulator("#tableTwo", {
        data:two,
        autoColumns:true,
        height:"500px",
        layout:"fitDataFill",
        // layout:"fitColumns",
        selectable:true,
        clipboard:true,
    });    

    //trigger download of data.xlsx file
    var sheets = {
    "sheetA": "#tableOne",
    "sheetB": "#tableTwo",
    };

    $("#download-xlsx").click(function(){
    table.download("xlsx", "AllData.xlsx", {sheets:sheets});
});
单击“下载”按钮时,excel工作簿将打开,其中包含两张工作表。第一张是第一张桌子,没关系。但第二张纸是空的。为什么会这样?

请查看此图。您需要将表变量放入要下载的sheets变量中创建空表0以合并并下载它们

var sheets = {
"Example Data1": table1,
    "Example Data2": table2
};

    downloadXlxs = function(){
table0.download("xlsx", "data.xlsx", {sheets:sheets});
};
var sheets = {
"Example Data1": table1,
    "Example Data2": table2
};

    downloadXlxs = function(){
table0.download("xlsx", "data.xlsx", {sheets:sheets});
};