导出excel表格和图片

    当需要把当前图表导出成excel或者图片时,首先在图表下面添加两个按钮:

 

	<div align="center">
	    <button id="report_export0">导出Excel</button>
	    <button id="report_image0">导出图片</button>
	</div>

 

     然后在js文件中,添加这两个按钮的响应事件。

    $("#report_export" + i).unbind("click");

$("#report_export" + i).bind("click",
{
	arg1: provinceID,
	arg2: fromDate,
	arg3: toDate,
	arg4: type,
	arg5: year,
	arg6: month
						},function(event){
	var data = event.data;
	exportReport(
									data.arg1,data.arg2,data.arg3,
									data.arg4,data.arg5,data.arg6);
					});
 

 

      然后导出excel的任务应该是在exportReport里完成的

 

function exportReport(provinceID, fromDate, toDate, type, year, month)
{
	var data = "provinceID=" + provinceID;
	data += "&from=" + fromDate;
	data += "&till=" + toDate;
	data += "&type=" + type;
	data += "&year=" + year;
	data += "&month=" + month;
	
	var option = {
			url: "ExportReport.action", 
			data:data,
			success: function(res, textStatus){
				if (res.match("^http"))
					window.location.href = res;
				else
					alert(res);
			},
			error:function(res,textStatus){
				alert(textStatus);
			}
	};
	$.ajax(option);
}
 

 

 

      绑定导出图片的方法如下:

$("#report_image" + i).unbind("click");
$("#report_image" + i).bind("click",
{
	chart: chart,
	title: title
},function(event){
	var data = event.data;
	data.chart.exportChart({filename: data.title});
});
 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值