轉帖|其它|編輯:郝浩|2010-10-14 14:43:21.000|閱讀 1965 次
概述:本文主要說說webchart和teechart控件導出圖片的方法,希望對大家有幫助。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
本文主要說說webchart和teechart控件導出圖片的方法,希望對大家有幫助。
webchart控件導出方法:
用個html控件添加onclick事件:onclick="go(document.getElementById('Chart1').src)"
“Chart1”是webchart控件的id
<iframe id="frame1" style="DISPLAY:none; Z-INDEX:103; LEFT:512px; POSITION:absolute; TOP:232px">
</iframe>
<script language="JScript">
var n=0;
function go(url){
n==0?new function(){frames("frame1").location=url,n=1}:null;
document.all("frame1").readyState!="complete"?setTimeout(go,10):so();
function so(){frames("frame1").document.execCommand("SaveAs"),n=0};
}
</script>
teechart控件圖片導出方法:
private void OutPicture_Click(object sender, System.Web.UI.ImageClickEventArgs e) //導出圖片按鈕,要確保項目根目錄下有ChartImage文件夾用于存放保存下來的圖片,然后利用下載文件導出
{
string C= Server.MapPath("ChartImage\")+"chart.png";
WebChart1.Chart.Export.Image.PNG.Save(C);
FileDownload(Server.MapPath("." + "/ChartImage/chart.png"));
}
private void FileDownload(string FullFileName)
{
FileInfo DownloadFile = new FileInfo(FullFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
Response.Close();
}
慧都2010促銷季開幕,TeeChart for .NET 8折促銷!詳情咨詢:400-700-1020或023-66090381活動詳情://fc6vip.cn/zh-CN/Products_cn/TeeChart_chinese.html
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:網絡轉載