EXcelテーブルとピクチャのエクスポート
2068 ワード
現在のグラフをexcelまたはピクチャにエクスポートする必要がある場合は、まずグラフの下に2つのボタンを追加します.
次にjsファイルに、この2つのボタンの応答イベントを追加します.
$("#report_export"+ i).unbind("click");
そしてexcelをエクスポートするタスクはexportReportで完了するはずです
画像をエクスポートする方法は次のとおりです.
<div align="center">
<button id="report_export0"> Excel</button>
<button id="report_image0"> </button>
</div>
次にjsファイルに、この2つのボタンの応答イベントを追加します.
$("#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});
});