如何在网页中显示 doc,xls,pdf,txt 等文件(文件数据都是以二进制形式保存到数据库的)?谢谢!

解决方案 »

  1.   

    从数据库取出来就是一个 byte[] 类型的数据,我数据库有一个字段可以识别文件是什么类型的,但不知该如何在网页中显示出来
      

  2.   

    把byte[]转换为string 再显示出来
      

  3.   

    怎么可能这样?BYTE网页就显示一个BYTE[]
      

  4.   

            System_Data sd = new System_Data();
            SqlDataReader myRead = sd.getSqlDataReader_For_Sql("select data from imagedata");
            if (myRead.Read())
            {
                Byte[] Buffer = (Byte[])myRead[0];
                this.Response.Clear();
                this.Response.ContentType = "application/msword";
                this.Response.AddHeader("Content-Disposition", "inline;   filename=" + "aaaa.doc");
                this.Response.BinaryWrite(Buffer);
                this.Response.End();
            }
            myRead.Close();图片和TXT可以用这个程序,但DOC,XLS是乱码
      

  5.   

    excel用application/vnd.ms-excel
    response.ContentType = "application/octet-stream";
    response.Charset = "UTF-8";
    response.ContentEncoding = System.Text.Encoding.UTF8;
    response.HeaderEncoding = System.Text.Encoding.UTF8;