将execl转换成二进制流再转换成字符串,然后再从字符串转换回execl

解决方案 »

  1.   

    System.IO.StreamReader mysr = new System.IO.StreamReader(strpath);
           //保证中文不乱码
            System.IO.StreamReader mysr = new System.IO.StreamReader(strpath, System.Text.Encoding.GetEncoding("gb2312"));strpath是你的文件路径,把mysr 放到dataset或datatable里
    试一下吧,我用好使
      

  2.   

    FileStream fs = File.Open( "1.xls" , FileMode.Open , FileAccess.Read , FileShare.ReadWrite);
    byte[] barray = new byte[fs.Length];
    int size =(int)fs.Length;
    fs.Read( barray , 0 , size );
    string str = System.Convert.ToBase64String( barray );
    fs.Close();
    byte[] btoexcel = System.Convert.FromBase64String( str );
    FileStream fs2 = File.Create( "2.xls");
    fs2.Write( btoexcel, 0, btoexcel.Length );
    fs2.Close();