我的word文件是存放在sql server的image字段内现在我直接用SqlDataReader取出
NodeContent=(byte[])sqlDataReader["NodeContent"];为byte[]类型现在我想把这个word文件的里的内容读出来放到一个string里请问如何做一定要先把这个文档先存成.doc文件?
可以不存直接获取出来最好在线等,先谢了
NodeContent=(byte[])sqlDataReader["NodeContent"];为byte[]类型现在我想把这个word文件的里的内容读出来放到一个string里请问如何做一定要先把这个文档先存成.doc文件?
可以不存直接获取出来最好在线等,先谢了
ApplicationClass Ob_ApplicationClass = new ApplicationClass();
Documents Ob_Documents= Ob_ApplicationClass.Documents;但是Ob_Documents能够打开一个byte[]的数据马?或者要数据流?
如果不行,那就只能现存成.doc?
有点晕阿
。NET类\论坛的问题解答\BS下WORD的解决办法(2003-11-11日调通)
http://dotnet.aspx.cc/ShowDetail.aspx?id=13C874E4-7FC7-4FD1-8CF6-DE9EF4469A9C
Word._Document oDoc;
object oMissing = Missing.Value;
object docBuiltInProps; object Source = @"DocPath";
object Unknown =Type.Missing;
oWord = new Word.Application();
try
{
oDoc = oWord.Documents.Open(ref Source,ref Unknown,
ref Unknown,ref Unknown,ref Unknown,
ref Unknown,ref Unknown,ref Unknown,
ref Unknown,ref Unknown,ref Unknown,
ref Unknown ); docBuiltInProps = oDoc.BuiltInDocumentProperties;
Type typeDocBuiltInProps = docBuiltInProps.GetType();
//获取作者
string index = "Author";
string propsValue;
object docAuthor = typeDocBuiltInProps.InvokeMember("Item",
BindingFlags.Default |
BindingFlags.GetProperty,
null,docBuiltInProps,
new object[] {index} );
Type typeDocAuthorProp = docAuthor.GetType();
propsValue = typeDocAuthorProp.InvokeMember("Value",
BindingFlags.Default |
BindingFlags.GetProperty,
null,docAuthor,
new object[] {} ).ToString();
MessageBox.Show( propsValue,"Author" ); //获取主题
index = "Subject";
propsValue = "The Subject";
object docSubjectProp = typeDocBuiltInProps.InvokeMember("Item",
BindingFlags.Default |
BindingFlags.GetProperty,
null,docBuiltInProps,
new object[] {index} );
Type typeDocSubjectProp = docSubjectProp.GetType();
propsValue = typeDocSubjectProp.InvokeMember("Value",
BindingFlags.Default |BindingFlags.GetProperty,
null,docSubjectProp,
new object[] {} ).ToString();
MessageBox.Show( propsValue,"Subject" ); }
finally
{
//关闭word进程
object save = false;
oWord.Quit(ref save,ref Unknown,ref Unknown);
System.Runtime.InteropServices.Marshal.ReleaseComObject(oWord);
}