1

我正在尝试在将图像添加到 StiReport 页面后添加一个表格。我已经尝试了下面的代码,但它抛出了一个异常:Invalid token ';' 在类、结构或接口成员声明中

        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();
4

1 回答 1

2

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

于 2014-02-10T12:08:16.290 回答