繁体   English   中英

用数据库C#中的图片替换Word文档中的文本

[英]Replace a text in Word doc with a picture from a database c#

我知道如何从数据库获取图片作为Byte数组:

string query2 = "SELECT Logo FROM Client WHERE CompanyName = '"+CN+"' ;";
using (SqlCeCommand command1 = new SqlCeCommand(query2, connection))
{
    try
    {
        SqlCeDataReader reader3 = command1.ExecuteReader();
        while (reader3.Read())
        {
            byte[] byteArray = (byte[])reader3["Logo"];
            Image img = byteArrayToImage(byteArray);
        }
    }
    catch (Exception excf)
    {
        MessageBox.Show(excf.Message);
    }
}

我知道如何使用图像的路径替换图像中的一些文本:

var kword = "#Logo#";
var sel = app.Selection;
sel.Find.Text = kword;
sel.Find.Execute(Replace: WdReplace.wdReplaceOne);
sel.Range.Select();
sel.InlineShapes.AddPicture(imagePath);

但是我不知道(而且我真的不知道如何用我从数据库中获得的图像替换某些文本。

我确定有明显的遗失之处,但我没有在Google上找到答案。

谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM