我的datatable里的第一列里存的的是image对象(或者对应的stream),其他列都是文本,怎么才能导出到excel中,把图片都显示出来呢

解决方案 »

  1.   

    比较麻烦,你可以先如下试试看看是否可以
    http://www.codeproject.com/csharp/excel_using_oledb.asp如果不行的话,就更麻烦了,
    你首先生成Image对象,然后把它复制到剪贴板中,然后再从中贴回到excel中。
      

  2.   

    给你个例子,连格式都保存下来System.IO.FileStream fs = new System.IO.FileStream(strFilePath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                    //文件流的书写器,指定编码
                    System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, System.Text.Encoding.UTF8);
                    sw.BaseStream.Seek(0, System.IO.SeekOrigin.End);
                    //HTML书写器
                    System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
                    //将HTML流输出到文件IO
                    grd.RenderControl(hw);                //书写完成
                    sw.Flush();
                    sw.Close();
                    fs.Close();为此,你可能要重载 VerifyRenderingInServerForm 方法
    并在ASPX文件头 把EnableEventValidation设定为false