我正在尝试使用下图所示的单元格创建一个表,同时使用Open XML生成Word文档,
为此,我编写了这样的代码
TableRow tr = new TableRow();
// Create a cell.
TableCell tc1 = new TableCell();
// Specify the width property of the table cell.
tc1.Append(new TableCellProperties(
new TableCellWidth() { Type = TableWidthUnitValues.Dxa, Width = "2400" }));
tc1.TableCellProperties.Shading = new Shading()
{
Fill = "#5DBCD2",
};
Paragraph systemPara = new Paragraph();
Run firstColumn = systemPara.AppendChild(new Run());
RunProperties runProps = new RunProperties();
Bold fontBoldForRunProps = new Bold();
Text fontText = new Text("System");
Color fontColor = new Color() { Val = "#FFFFFF" };
runProps.Append(fontBoldForRunProps);
runProps.Append(fontText);
runProps.Append(fontColor);
firstColumn.Append(runProps);
tc1.Append(systemPara);
tr.Append(tc1);
以某种方式,我无法将字体颜色设置为white
,结果像文本System
的字体颜色一样变成黑色。
有人可以向我指出上面代码在哪里做错了正确的方向。
非常感谢。