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();
            
        }

你可能感兴趣的:(asp.net类)