如何在Stimulsoft中以编程方式创建表?

时间:2014-02-06 15:22:30

标签: c# .net reporting stimulsoft

我想在将图像添加到StiReport页面后添加表格。我尝试了下面的代码,但它引发了一个例外: 无效的令牌';'在类,结构或接口成员声明中

        stiReport1.Pages[0].Components.Clear();
        StiImage image = new StiImage();
        image.Left = 0;
        image.Top = 0;
        image.Width = 7;
        image.Height = 4;
        image.Stretch = true;
        //An image name should be unique in your report
        image.Name = "MyUniqueName";

        //Assign an image
        image.Image = bmp;

        //Add a component with an image with a report
        stiReport1.Pages[0].Components.Add(image);

        //Create Table
        StiTable table = new StiTable();
        table.Name = "MyUniqueName2";
        table.AutoWidth = StiTableAutoWidth.Table;
        table.AutoWidthType = StiTableAutoWidthType.FullTable;
        table.ColumnCount = 2;
        table.RowCount = 3;
        table.HeaderRowsCount = 1;
        table.FooterRowsCount = 0;
        table.Width = stiReport1.Pages[0].Width;
        table.Height = stiReport1.Pages[0].GridSize;
        //Set text on header
        StiTableCell headerCell = new StiTableCell();
        headerCell.Text.Value = "ddd";
        headerCell.ID = 0;
      //  headerCell.Border = new StiBorder(StiBorderSides.All, Color.FromArgb(0, 0, 0), 0, StiPenStyle.Solid);
        headerCell.HorAlignment = StiTextHorAlignment.Center;
        headerCell.VertAlignment = StiVertAlignment.Center;
        headerCell.WordWrap = true;
        headerCell.Font = new System.Drawing.Font("B Nazanin", 7F, System.Drawing.FontStyle.Bold);
        headerCell.Height = 3;
        table.TableStyle = StiTableStyle.Style32;

        table.Components.Clear();
        table.Components.Add(headerCell);
         stiReport1.Pages[0].Components.Add(table);
        //
        stiReport1.Compile();
        stiReport1.Render();
        stiReport1.Show();

1 个答案:

答案 0 :(得分:2)

您应该至少创建一个StiTableCell。 StiTable是非常复杂的组件。要了解如何在代码中创建它,请尝试在Designer中创建带有表带的报表,然后查看代码选项卡。