AutoVueX控件,一个显示好多种文件格式的控件,出现错误是随机的,好像是控件试用期已过,但用VB还有delphi调用该控件都是正常的,很奇怪...

解决方案 »

  1.   

    谢谢各位,直接调用控件还是没解决,用的曲线救国的方式,用VB调用控件编译成可执行程序,然后用C#调用该外部文件,传递参数.
      

  2.   


    你在.cs文件中加入下面这个函数:public void ToExcel(System.Web.UI.Control ctl)  
    {
    // HttpContext.Current.Response.Charset ="GB2312";
    HttpContext.Current.Response.Charset ="";
    HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=money.xls");

    HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("GB2312"); 
    HttpContext.Current.Response.ContentType ="application/ms-excel";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
    ctl.Page.EnableViewState =false;
    System.IO.StringWriter  tw = new System.IO.StringWriter() ;
    System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
    ctl.RenderControl(hw);
    HttpContext.Current.Response.Write(tw.ToString());
    HttpContext.Current.Response.End();
    }然后再调用:ToExcel(datagrid1)