txt格式的和图片按照字节流读取的,而doc是带格式的流文件,通过特定的编码才能获得正确的文字信息。
string xx,yy; 
Word.ApplicationClass oWord = new Word.ApplicationClass(); 
Word.Document oDoc; 
Word.Range oRange; 
Word.Table otable; 
Word.Selection  oselection; 
object a = Missing.Value; 
object b = Missing.Value; 
object filename=@"c:\test.doc"; 
oDoc = oWord.Documents.Open(ref filename,ref a,ref a,ref a,ref 
//or oDoc = oWord.Documents.Add(ref a,ref a,ref a,ref a); 
a,ref a,ref a,ref a,ref a,ref a,ref a,ref a);   
oWord.Visible = true; 
oDoc = oWord.ActiveDocument 
oRange = oDoc.Range(ref a,ref b); 
oRange.Rows.Count = 9; 
oRange.Select; 
xx =oRange.Text;   
otable = oDoc.Tables.Item(1); 
otable.Select; 
yy = otable.Cell(0,1).Range.Text;

解决方案 »

  1.   

    必须要引用Word.ApplicationClass 组件??
    直接从浏览器中打开不可以吗?还有没有其他方法?
      

  2.   

    office200可以直接在ie中大开  但是office2003 好象不可以
      

  3.   

    打不开的。只能用word的组件,或者
    Response.Buffer = true;
    Response.ContentType ="Application/x-msword";          Response.BinaryWrite((byte[])reader.GetValue(0));
    但是IE总是死,烦
      

  4.   

    StreamReader sr = new StreamReader("c:\\1.txt",System.Text.Encoding.Default);
      

  5.   

    byte[] filedata = (byte[])ds.Tables[0].Rows[0]["filedata"];
    Response.AddHeader("Content-Type", "application/msword"); 
    Response.AddHeader("Content-Disposition", "inline;";
    Response.BinaryWrite(filedata);
    Response.End();