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;
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;
直接从浏览器中打开不可以吗?还有没有其他方法?
Response.Buffer = true;
Response.ContentType ="Application/x-msword"; Response.BinaryWrite((byte[])reader.GetValue(0));
但是IE总是死,烦
Response.AddHeader("Content-Type", "application/msword");
Response.AddHeader("Content-Disposition", "inline;";
Response.BinaryWrite(filedata);
Response.End();