生成Xtrareport

时间:2014-09-12 06:48:33

标签: devexpress xtrareport

我想以适当的格式在Xtrareport中生成动态表。

所以我正在使用此代码

   dynamicTable.Borders = DevExpress.XtraPrinting.BorderSide.All

        dynamicTable.BorderWidth = 1

但是我没有按照我的意愿提供适当的输出..

通过逐行分隔每个单元格来生成表格,因此它不会给出表格外观。!

[1]: http://i.stack.imgur.com/iaKl9.png

完整的代码:

 Dim label As New XRLabel()
    label.Width = 500
    label.Font = New System.Drawing.Font("Verdana", 10.0F, FontStyle.Bold)
    PageHeader1.Controls.Add(label)

    If rowsCount > 0 Then
        Dim padding As Integer = 5
        Dim tableWidth As Integer = Me.PageWidth - Me.Margins.Left - Me.Margins.Right - padding * 2

        Dim dynamicTable As XRTable = XRTable.CreateTable(New Rectangle(padding, 1, tableWidth, 40), 1, 0) ' table column count

        dynamicTable.Width = tableWidth
        dynamicTable.Rows.FirstRow.Width = tableWidth
        dynamicTable.Borders = DevExpress.XtraPrinting.BorderSide.All
        'dynamicTable.Borders = DirectCast(((DevExpress.XtraPrinting.BorderSide.Left Or DevExpress.XtraPrinting.BorderSide.Top) Or DevExpress.XtraPrinting.BorderSide.Right) Or DevExpress.XtraPrinting.BorderSide.Bottom, DevExpress.XtraPrinting.BorderSide)
        dynamicTable.BorderWidth = 1
        Dim i As Integer = 0
        dynamicTable.BeginInit()
        For Each dc As DataColumn In ds.Tables(0).Columns

            Dim cell As New XRTableCell()

            Dim binding As New XRBinding("Text", ds, ds.Tables(0).Columns(i).ColumnName)
            cell.DataBindings.Add(binding)
            cell.CanGrow = False
            cell.CanShrink = True
            cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter
            'cell.WidthF = 10 
            'cell.Width = 20
            cell.Text = dc.ColumnName
            dynamicTable.Rows.FirstRow.Cells.Add(cell)



            i += 1

        Next dc


        dynamicTable.Font = New System.Drawing.Font("Verdana", 8.0F)
        dynamicTable.AdjustSize()
        dynamicTable.EndInit()
        Detail.Controls.Add(dynamicTable)
        'label.Text = String.Format("Data table: {0}", Test)

        Me.DataSource = ds
        Me.DataMember = Test

0 个答案:

没有答案