MigraDoc单元格背景颜色问题

时间:2019-01-11 00:28:57

标签: c# migradoc

我已经创建了一个表格。第一行中有3列,第二行中有1列(向右合并2),最后一行中有3列。
我试图在顶部和底部的行中设置单元格的背景色,但它只会让我设置左上角的单元格的颜色?但是,如果我增加表格的高度以使其不适合页面,则第三行的整个颜色正确,但是第一行只有第一个单元格是正确的!

public static void CreateReport(Document report)
{
    var margin = Unit.FromMillimeter(5);
    var wrapperHeight = Unit.FromMillimeter(15);
    var wrapperWidth = Unit.FromMillimeter(60);
    var centralWidth = Unit.FromMillimeter(170);
    var mainHeight = Unit.FromMillimeter(169);

    report.DefaultPageSetup.Orientation = Orientation.Landscape;
    report.DefaultPageSetup.LeftMargin = 
    report.DefaultPageSetup.TopMargin =
    report.DefaultPageSetup.RightMargin = 
    report.DefaultPageSetup.BottomMargin = margin;

    report.AddSection();
    var layout = report.LastSection.AddTable();
    layout.Borders.Visible = true;

    var leftColumn = layout.AddColumn();
    leftColumn.Width = wrapperWidth;

    var centralColumn = layout.AddColumn();
    centralColumn.Width = centralWidth;

    var rightColumn = layout.AddColumn();
    rightColumn.Width = wrapperWidth;

    var topRow = layout.AddRow();
    topRow.Height = wrapperHeight;

    var middleRow = layout.AddRow();

    var bottomRow = layout.AddRow();
    bottomRow.Height = wrapperHeight;

    for (int column = 0; column < 3; column++)
    {
        layout[0, column].Shading.Color = new Color(0x595959); // Works
        layout[0, column].Shading.Color = new Color(0x595959); // ??
        layout[0, column].Shading.Color = new Color(0x595959); // ??
        layout[2, column].Shading.Color = new Color(0x595959); // ??
        layout[2, column].Shading.Color = new Color(0x595959); // ??
        layout[2, column].Shading.Color = new Color(0x595959); // ??
    }

    layout[0, 0].Format.Font.Size = 31;
    layout[0, 0].Format.Font.Color = Colors.Blue;
    layout[0, 0].AddParagraph("TITLE");

    layout[0, 2].Format.Font.Size = 31;
    layout[0, 2].Format.Font.Color = Colors.Blue;
    layout[0, 2].AddParagraph("TITLE 2");

    middleRow.Height = mainHeight;
    middleRow.Cells[0].MergeRight = 2;
}

enter image description here

0 个答案:

没有答案