【问题标题】:read word doc file stored as blob and convert its content to string读取存储为 blob 的 word doc 文件并将其内容转换为字符串
【发布时间】:2015-04-21 01:39:05
【问题描述】:

我在 Mysql 上有一个存储为 BLOB 的 word 文档,我正在尝试使用 c# 读取它,获取其中的文本。有人可以给我关于如何做到这一点的简短代码。到目前为止,我已经设法使用以下方法从数据库中读取字节:

using (MySqlConnection conn = new MySqlConnection())
{
    conn.ConnectionString = "connection string is here";
    conn.Open();
    MySqlCommand command = new MySqlCommand("select filename, document_content from job_db.person_documents where doc_type = 'application/msword' limit 1;", conn);
    using (MySqlDataReader reader = command.ExecuteReader())
    {
        // while there is another record present
        while (reader.Read())
        {
            Byte[] bytData = (byte[])reader[1];        
        }
    }
    conn.Close();
}

【问题讨论】:

    标签: c# mysql interop blob console-application


    【解决方案1】:

    有一篇关于从内存中读取开放 XML 文档的办公室谈话文章。

    https://msdn.microsoft.com/en-us/library/ee945362%28v=office.11%29.aspx

    要访问这些方法,您需要 Open XML SDK。

    http://www.microsoft.com/en-au/download/details.aspx?id=30425

    希望这足以让您入门。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-23
      • 2021-09-15
      • 2012-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多