Stimulsoft Reports.Net示例演示:WinForms 类别中在运行时使用表创建新 告

此示例显示如何在运行系统中创建带有表格的简单 告。在这个示例项目中,您可以为表设置一些属性。

此示例显示如何在运行系统中创建带有表格的简单 告。在这个示例项目中,您可以为表设置一些属性。使用表格组件,您可以创建一个带有标题和总计而没有其他波段的 告。在这种情况下,某些表格行将成为数据的页眉和页脚。首先,创建一个新 告并连接到数据:

private void PrintDataGrid(DataGrid sender){DataView dataView = (DataView)sender.DataSource;StiReport report = new StiReport();report.ScriptLanguage = StiReportLanguageType.CSharp;// Add data to datastorereport.RegData("view", dataView);// Fill dictionaryreport.Dictionary.Synchronize();...

接下来,在 表页面添加 Table 组件:

...StiPage page = report.Pages.Items[0];// Create TableStiTable table = new StiTable();table.Name = "Table1";if (rbAWNone.Checked)table.AutoWidth = StiTableAutoWidth.None;else if (rbAWPage.Checked)table.AutoWidth = StiTableAutoWidth.Page;elsetable.AutoWidth = StiTableAutoWidth.Table;if (rbAWTNone.Checked)table.AutoWidthType = StiTableAutoWidthType.None;else if (rbAWTFullTable.Checked)table.AutoWidthType = StiTableAutoWidthType.FullTable;else table.AutoWidthType = StiTableAutoWidthType.LastColumns;...

接下来,在表中定义一些列和行:

...table.ColumnCount = 3;table.RowCount = 3;...

接下来,定义表中Header的行数和Footer的行数:

...table.HeaderRowsCount = 1;table.FooterRowsCount = 1;...

接下来,定义 Table 组件的其他选项:

...table.Width = page.Width;table.Height = page.GridSize * 12;table.DataSourceName = "view" + dataView.Table.TableName;page.Components.Add(table);table.CreateCell();table.TableStyleFX = new StiTable27StyleFX();table.TableStyle = Stimulsoft.Report.Components.Table.StiTableStyle.Style59;int indexHeaderCell = 0;int indexDataCell = 3;...

接下来,添加标题文本和对单元格中数据字段的引用:

...foreach (DataColumn column in dataView.Table.Columns){// Set text on headerStiTableCell headerCell = table.Components[indexHeaderCell] as StiTableCell;headerCell.Text.Value = column.Caption;headerCell.HorAlignment = StiTextHorAlignment.Center;headerCell.VertAlignment = StiVertAlignment.Center;StiTableCell dataCell = table.Components[indexDataCell] as StiTableCell;dataCell.Text.Value = "{view" + dataView.Table.TableName + "." +Stimulsoft.Report.CodeDom.StiCodeDomSerializator.ReplaceSymbols(column.ColumnName) + "}";dataCell.Border = new StiBorder(StiBorderSides.All, Color.FromArgb(32, 178, 170), 1, StiPenStyle.Dash);indexHeaderCell++;indexDataCell++;}StiTableCell dataCheckBoxCell = table.Components[indexDataCell - 1] as StiTableCell;dataCheckBoxCell.CellType = StiTablceCellType.CheckBox;...

接下来,在单元格中添加一个 total 函数:

...// Set text on footerStiTableCell footerCell = table.Components[table.Components.Count - 1] as StiTableCell;footerCell.Text.Value = "Count - {Count()}";footerCell.Font = new Font("Arial", 15, FontStyle.Bold);footerCell.VertAlignment = StiVertAlignment.Center;footerCell.HorAlignment = StiTextHorAlignment.Center;...

最后,渲染 告并在查看器中显示:

...// Render without progress barreport.Render(false);report.Show();}

在下面的屏幕截图中,您可以看到示例代码的结果:

Stimulsoft Reports.Net示例演示:在WinForms 类别中在运行系统中创建一个简单的 告

Aspose、E-iceblue、FastReport、Stimulsoft等文档/ 表图表类开发工具享超低折扣,如有需要可直接联系在线客服。

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年8月12日
下一篇 2021年8月12日

相关推荐

发表回复

登录后才能评论