使用值作为字符串导出excel中的Highcharts数据

时间:2016-01-20 07:09:23

标签: excel highcharts export

我想将highcharts数据导出为ex​​cel。我能够做到这一点唯一的问题是我想在数据中导出字符串。但是,highcharts不会将字符串作为数据值导出,而在excel表中它会返回undefined。

    $(function () {
    // Create the chart
    var options1 =
        {

            chart: {
                renderTo: 'container0',
                borderColor: '#dddddd',
                borderWidth: 1,
                borderRadius: 10,
                type: 'column',
                spacingBottom: 20,
                spacingTop: 20,
                spacingLeft: 20,
                spacingRight: 20,
                width: 378,
                height: 237,
                // backgroundColor: 'blue'
            },

            navigation: {
                buttonOptions: {
                    verticalAlign: 'top',
                    y: -9,
                    x: 15,
                    symbolSize: 10,
                    symbolHeight: 30,
                    symbolStrokeWidth: 0,
                    strokeWidth: 0,
                    theme: {
                        fill: 'black',
                        zIndex: 6
                    },
                    ry: 5,
                    rx: 5
                }
            },


            credits: {
                enabled: false,
                text: 'Only top 10 records displayed',
                position: {
                    align: 'right',
                    y: -5

                },
                href: "javascript:void(0)",
                style: {
                    fontSize: '10',
                    cursor: "normal"
                }
            },

            exporting: {
                sourceWidth: 480,
                sourceHeight: 300,
                scale: 1
            },


            title: {
                style: {
                    'fontSize': '1em'
                },
                useHTML: true,
                x: -27,
                y: 8,
                text: null
            },

            xAxis: {
                name: "Fruit",
                categories: ['11/15/2015','11/22/2015','11/29/2015','12/6/2015','12/13/2015','12/20/2015','12/27/2015']
                    },

               labels: {
                    style: {
                        fontSize: '9px'
                    }
                },


            yAxis: {
                title: {
                    text: ''
                },
                min: 0,
                max: 150,
                tickInterval: 20,
            },
            legend: {
                enabled: false
            },
            plotOptions: {
                series: {
                    borderWidth: 0,
                    dataLabels: {
                        enabled: true,
                        style: {
                            fontWeight: 'normal',
                            color: 'grey'
                        },
                        format: '{point.y}',
                    },
                    shadow: {
                        width: 5,
                    }
                }
            },

            tooltip: {
                headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
                pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
            },

            series: [{
                name: 'Accounts Reached',
                color: {
                    linearGradient: { x1: 1, x2: 1, y1: 1, y2: 0 },
                    stops: [
                        [0, '#12486d'],
                        [1, '#279ef2']
                    ]
                },
                pointWidth: 30,
                data: [19, 132, 25, 28, 82, 1, 1],
                visible:false
            }, {
                name: 'Week',
                color: {
                    linearGradient: { x1: 1, x2: 1, y1: 1, y2: 0 },
                    stops: [
                        [0, '#12486d'],
                        [1, '#279ef2']
                    ]
                },
                visible:false,
                pointWidth: 30,
                data: [19, 132, 25, 28, 82, 1, 1]
            }, {
                name: 'Leads',
                color: {
                    linearGradient: { x1: 1, x2: 1, y1: 1, y2: 0 },
                    stops: [
                        [0, '#12486d'],
                        [1, '#279ef2']
                    ]
                },
                pointWidth: 30,
                data: [19, 166, 39, 37, 107, 1, 1]
            }, {
                name: 'Campaign ID',
                color: {
                    linearGradient: { x1: 1, x2: 1, y1: 1, y2: 0 },
                    stops: [
                        [0, '#12486d'],
                        [1, '#279ef2']
                    ]
                },
                pointWidth: 30,
                data: [18223, 18223, 18223, 18223, 18223, 18223, 18223],
                visible:false
            }, {
                name: 'week start2',
                color: {
                    linearGradient: { x1: 1, x2: 1, y1: 1, y2: 0 },
                    stops: [
                        [0, '#12486d'],
                        [1, '#279ef2']
                    ]
                },
                pointWidth: 30,
                data: ["Mon", "Mon", "Mon", "Mon", "Mon", "Mon", "Mon"],
                visible: false
            }

            ]
        }

    var chart = new Highcharts.Chart(options1);
});

我不想在图表上显示字符串数据我唯一的要求是在excel中导出多个列,这些列也可能包含数据字符串。

1 个答案:

答案 0 :(得分:0)

默认情况下,您的图表不会打印此系列(带文本),因为Highcharts需要数字值(不支持字符串作为数据)。因此,出口也不会打印这些要点。