如何在MigraDoc表中设置单元格的背景颜色

Jef*_*f G 12 pdfsharp migradoc c#-4.0

我有一个MigraDoc表,我指定行高0.75厘米,文本在单元格的中间垂直对齐.当我将cell.Format.Shading.Color设置为非白色的东西时,边框附近仍有一部分单元格在四边显示为白色.

我发现我可以通过设置column删除文本左侧和右侧的白色部分.LeftPadding = 0和column.RightPadding = 0.但是,我无法弄清楚如何在文本的顶部/底部获得白色条纹消失而不影响文本的垂直对齐.如果我将段落线高度更改为0.75厘米,条纹将消失,但文本在单元格内底部对齐.我无法设置列着色颜色,因为列中的每个单元格都包含不同的颜色.有没有人知道强制段落垂直填充单元格的方法(或者让单元格中的背景颜色均匀)?

以下是我的代码示例(在C#中),其中表的类型为MigraDoc.DocumentObjectModel.Tables.Table:

...

// Add a column at index #2
var column = table.AddColumn();
column.LeftPadding  = 0;
column.RightPadding = 0;

// Add more columns
... 

// Iterate through the data printed in each row
foreach (var rowData in myData)
{
    // Create a row for the data
    var row = table.AddRow();
    row.Height = ".75cm";
    row.Format.Font.Size = 11;
    row.VerticalAlignment = VerticalAlignment.Center;

    ...

    // The following is for illustrative purposes... the actual
    //     colors and text is determined by the data within the cell
    var cell = row.Cells[2];
    cell.Format.Shading.Color = Colors.Black;
    cell.Format.Font.Color    = Colors.White;
    var paragraph = cell.AddParagraph("Example");

    ...
}
Run Code Online (Sandbox Code Playgroud)

Je *_*not 21

尝试cell.Shading.Color代替cell.Format.Shading.Color- 前者设置单元格的颜色,后者设置文本背景的颜色(然后单元格的填充将具有不同的颜色).