RadFlowDocument调整表格单元格宽度

时间:2016-01-22 20:59:09

标签: asp.net telerik

我正在使用Telerik 2016 Q1,Visual Studio 2013,visual basic和MVC。我正在尝试使用RadFlowDocument生成pdf。我的pdf包含一个表,其中包含一个员工姓名行,后面是分配给该员工的每个项目的行。重复此信息,以便将有一个带有名称的行,然后是包含项目的4行,然后是另一个名称,后跟更多项目。

员工姓名的行应该跨越表格的宽度,并且具有不同的背景颜色,以使其脱颖而出。我已经尝试调整tableCell.PrefferedWidth,但这似乎对输出没有任何影响。

以下是创建表格的循环:

    For i As Integer = 0 To numberOfSubordinates - 1
        Dim currentSubordinate As Subordinate = neededInformation.Subordinates(i)

        Dim employeeNameRow As TableRow = itemTable.Rows.AddTableRow()
        Dim employeeNameCell As TableCell = employeeNameRow.Cells.AddTableCell()
        employeeNameCell.Blocks.AddParagraph.Inlines.AddRun(currentSubordinate.Name)
        employeeNameCell.Shading.BackgroundColor = cellBackground
        employeeNameCell.PreferredWidth = New TableWidthUnit(150)

        For j As Integer = 0 To currentSubordinate.Items.Count - 1
            Dim row As TableRow = itemTable.Rows.AddTableRow()

            Dim itemTypeCell As TableCell = row.Cells.AddTableCell()
            Dim manufacturerCell As TableCell = row.Cells.AddTableCell()
            Dim modelCell As TableCell = row.Cells.AddTableCell()
            Dim locationCell As TableCell = row.Cells.AddTableCell()
            Dim serialNumberCell As TableCell = row.Cells.AddTableCell()
            Dim tagNumberCell As TableCell = row.Cells.AddTableCell()

            Dim currentItem = currentSubordinate.Items(j)

            itemTypeCell.Blocks.AddParagraph().Inlines.AddRun(currentItem.ItemType)
            manufacturerCell.Blocks.AddParagraph.Inlines.AddRun(currentItem.Manufacturer)
            modelCell.Blocks.AddParagraph.Inlines.AddRun(currentItem.Model)
            locationCell.Blocks.AddParagraph.Inlines.AddRun(currentItem.Location)
            serialNumberCell.Blocks.AddParagraph.Inlines.AddRun(currentItem.SerialNumber)
            tagNumberCell.Blocks.AddParagraph.Inlines.AddRun(currentItem.MCSCTagNumber)
        Next

    Next

如何扩展员工姓名行,使名称不会换行,背景颜色会延长行的长度?

1 个答案:

答案 0 :(得分:0)

调整cell.ColumnSpan。如果此表有6列,为了有一个跨越整个表的行,调整应该是:employeeNameCell.ColumnSpan = 6

相关问题