Javascript 是否将使用Highcharts创建的多个饼图保存为图像并将其导出到Excel?

Javascript 是否将使用Highcharts创建的多个饼图保存为图像并将其导出到Excel?,javascript,highcharts,phpexcel,Javascript,Highcharts,Phpexcel,我有多个饼图是使用highcharts.js创建的。我已经构建了一个Excel导出,将表格从HMTL页面导出到Excel。现在,我想导出饼图,这样当用户单击“导出到Excel”按钮时,所有内容都在Excel文件中。这可能吗?如果没有,我能否将图表保存为图像,并将其与其他信息一起插入导出 我尝试过的: 我花了很多时间寻找解决方案,但我不知道如何才能做到这一点 更新 我的PHP脚本: /* //some code to get the date from database and encode it

我有多个饼图是使用highcharts.js创建的。我已经构建了一个Excel导出,将表格从HMTL页面导出到Excel。现在,我想导出饼图,这样当用户单击“导出到Excel”按钮时,所有内容都在Excel文件中。这可能吗?如果没有,我能否将图表保存为图像,并将其与其他信息一起插入导出

我尝试过的:

我花了很多时间寻找解决方案,但我不知道如何才能做到这一点

更新

我的PHP脚本:

/*
//some code to get the date from database and encode it to json
*/
if(isset($_GET["getuser1"])){
    echo json_encode($getuser1);
    die;

}
 $.ajax({
            url:'userreport.php',
            type:'POST',
            data:{
                "getuser1":"",
                "from":date},
            success:function(data){
                //console.log(data);
                data=$.parseJSON(data);
             var user1=[];


             var count=0;

             for(key in data){
                 if (data.hasOwnProperty(key)) {

                     user1.push({"name":key,"y":data[key]});

                     count++;

                    }
                }

            // console.log(user1);
    //////////////////////////////

    Highcharts.chart('user1', {
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: true,
            type: 'pie'
        },
        title: {
            text: 'user1'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.y}  (  <b>{point.percentage:.1f}%  )',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                },
                showInLegend: true
            }
        },
        series: [{
            name: 'Brands',
            colorByPoint: true,
            data:user1

                }]
    }); 
                }

            });
我的javascript:

/*
//some code to get the date from database and encode it to json
*/
if(isset($_GET["getuser1"])){
    echo json_encode($getuser1);
    die;

}
 $.ajax({
            url:'userreport.php',
            type:'POST',
            data:{
                "getuser1":"",
                "from":date},
            success:function(data){
                //console.log(data);
                data=$.parseJSON(data);
             var user1=[];


             var count=0;

             for(key in data){
                 if (data.hasOwnProperty(key)) {

                     user1.push({"name":key,"y":data[key]});

                     count++;

                    }
                }

            // console.log(user1);
    //////////////////////////////

    Highcharts.chart('user1', {
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: true,
            type: 'pie'
        },
        title: {
            text: 'user1'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.y}  (  <b>{point.percentage:.1f}%  )',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                },
                showInLegend: true
            }
        },
        series: [{
            name: 'Brands',
            colorByPoint: true,
            data:user1

                }]
    }); 
                }

            });
$.ajax({
url:'userreport.php',
类型:'POST',
数据:{
“getuser1”:”,
“从”:日期},
成功:功能(数据){
//控制台日志(数据);
data=$.parseJSON(数据);
var user1=[];
var计数=0;
用于(输入数据){
if(data.hasOwnProperty(key)){
user1.push({“name”:key,“y”:data[key]});
计数++;
}
}
//console.log(user1);
//////////////////////////////
Highcharts.chart('user1'{
图表:{
plotBackgroundColor:null,
plotBorderWidth:null,
是的,
键入:“馅饼”
},
标题:{
文本:“user1”
},
工具提示:{
pointFormat:“{series.name}:{point.percentage:.1f}%”
},
打印选项:{
馅饼:{
allowPointSelect:true,
光标:“指针”,
数据标签:{
启用:对,
格式:{point.name}:{point.y}({point.percentage:.1f}%),
风格:{
颜色:(Highcharts.theme&&Highcharts.theme.ContractTextColor)| |“黑色”
}
},
showInLegend:对
}
},
系列:[{
名称:'品牌',
colorByPoint:对,
数据:user1
}]
}); 
}
});

您能提供更多信息吗?如何生成图像?您是否使用highcharts的内置导出功能?我更新了我的问题。Hchharts提供了导出模块(),可以将图表导出为PDF、PNG、JPG或SVG格式。您只需要找到将该图像存储在excel文件中的方法。您还可以基于系列数据()在excel中创建图表。如果您使用的是PHPExcel,这个网站应该会有帮助:。是的,确切地说,现在唯一的方法是将图表存储为图像并将其插入excel文件,但我认为这件事以前没有做过,所以这是同样的问题,怎么可能呢?