获取Word文档内容并将其转换为字节数组. [英] Get word document content and convert it to array of bytes.

查看:250
本文介绍了获取Word文档内容并将其转换为字节数组.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在使用Word 2007加载项,我希望此加载项获取此活动Word文档的全部内容,然后将其转换为字节数组,而无需将文档保存在文件流中. br/> 我已经成功获取了此文档中的文本,并在不保存文档的情况下将其转换为字节数组,但这还不够.

因此,作为我的问题的摘要:
1.我想在此活动的Word文档中获取整个内容(文本,图像等),并将其转换为字节数组.
2.我希望在将文档内容转换为字节数组时保留该文档内容的 format .因为稍后我将获得该内容(作为字节数组),并将其转换为字节原创.
文档内容存储在数据库中.

我希望我能清楚地解释我的问题,如果有人可以帮助我,我将不胜感激.

预先谢谢您,
:)

Hello,,

I am working on an Word 2007 add-in,I want this add-in to get the whole content of this active word document and convert it to array of bytes without saving the document in the filestream.
I have succeeded in getting the text in this document and convert it to an array of bytes without saving the document,but that is not enough.

So as a summary of my issuess:
1. I want to get the whole content (text,image..etc)in this active word document and convert it to an array of bytes.
2. I want the format of this document content to be preserved when I convert it to an array of bytes.Because later on I will get this content(as an array of bytes)back and convert to its original.
The document content in stored in a database.

I hope I explained my problem clear enough,I''d appreciate it if anyone can help me with it.

Thank you in advance,,
:)

推荐答案

以获取Word文档中的全部内容.请参见下面的代码
To get whole Content in word document. Please see the Code Below
Application wordApp = new ApplicationClass();
 Document doc = null;

 // path where word File is uploaded
 public string file_Name = "GeekGirl.doc";
  object uploadFilePath="C:\FolderName" +file_Name ;

           object missing = System.Reflection.Missing.Value;
             object setFalse = false;
             object saveChanges = WdSaveOptions.wdSaveChanges;
             object setTrue = true;
             doc = wordApp.Documents.Open( ref uploadFilePath
             ref setFalse, ref setFalse, ref setFalse, ref missing,
             ref missing, ref setTrue, ref missing, ref missing,
             ref missing, ref missing, ref setFalse, ref setFalse,
             ref missing, ref setTrue, ref missing);


这篇关于获取Word文档内容并将其转换为字节数组.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆