Change font color in OpenXML word document (C#)

后端 未结 4 1196
小鲜肉
小鲜肉 2021-02-14 04:58

I\'ve been searching for hours and I just can\'t seem to find a solid answer for this. I have an existing document with content controls that I need to edit the text in with ex

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-14 05:41

    Well, I kind of brute forced my way to the answer, but it works.

    List runProps = element.Descendants().ToList();
    foreach (RunProperties rp in runProps)
    {
        rp.Color = new DocumentFormat.OpenXml.Wordprocessing.Color() { Val = "0EBFE9" };
    }
    

    If anyone has a more elegant solution please add it and I'll upvote it.

提交回复
热议问题