123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?xml version="1.0" encoding="utf-8"?>
- <Report ScriptLanguage="CSharp" ReportInfo.Description="Demonstrates how to print multiple Table rows with a script. To do this: - select the Table object; - go to the "Properties" window and click the "Events" button to view a list of available events; - doubleclick the "ManualBuild" event; - you will see an empty event handler. You need to print rows using the "TableObject.PrintRow" method; in each row, you must also print all the columns (using "PrintColumns" method). See the script's code for more details. When you run a report, the Table will repeat a row and fill it with data." ReportInfo.Created="01/17/2008 20:40:24" ReportInfo.Modified="04/07/2023 18:06:50" ReportInfo.CreatorVersion="1.0.0.0">
- <ScriptText>using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Data;
- using FastReport;
- using FastReport.Data;
- using FastReport.Dialog;
- using FastReport.Barcode;
- using FastReport.Table;
- using FastReport.Utils;
- namespace FastReport
- {
- public class ReportScript
- {
- private void Table1_ManualBuild(object sender, EventArgs e)
- {
- // get the data source by its name
- DataSourceBase rowData = Report.GetDataSource("Products");
- // init the data source
- rowData.Init();
-
- // print the first table row - it is a header
- Table1.PrintRow(0);
- // each PrintRow call must be followed by either PrintColumn or PrintColumns call
- // to print cells on the row
- Table1.PrintColumns();
-
- // now enumerate the data source and print the table body
- while (rowData.HasMoreRows)
- {
- // print the table body
- Table1.PrintRow(1);
- Table1.PrintColumns();
-
- // go next data source row
- rowData.Next();
- }
-
- // print the last table row - it is a footer
- Table1.PrintRow(2);
- Table1.PrintColumns();
- }
- }
- }
- </ScriptText>
- <Dictionary>
- <TableDataSource Name="Products" ReferenceName="NorthWind.Products" DataType="System.Int32" Enabled="true">
- <Column Name="ProductID" DataType="System.Int32"/>
- <Column Name="ProductName" DataType="System.String"/>
- <Column Name="SupplierID" DataType="System.Int32"/>
- <Column Name="CategoryID" DataType="System.Int32"/>
- <Column Name="QuantityPerUnit" DataType="System.String"/>
- <Column Name="UnitPrice" DataType="System.Decimal"/>
- <Column Name="UnitsInStock" DataType="System.Int16"/>
- <Column Name="UnitsOnOrder" DataType="System.Int16"/>
- <Column Name="ReorderLevel" DataType="System.Int16"/>
- <Column Name="Discontinued" DataType="System.Boolean" BindableControl="CheckBox"/>
- <Column Name="EAN13" DataType="System.String"/>
- </TableDataSource>
- </Dictionary>
- <ReportPage Name="Page1" Watermark.Font="Arial, 60pt">
- <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8" CanGrow="true">
- <TextObject Name="Text2" Width="718.2" Height="37.8" Text="PRODUCTS LIST" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
- </ReportTitleBand>
- <DataBand Name="Data1" Top="39.8" Width="718.2" Height="153.67">
- <TableObject Name="Table1" Left="9.45" Top="11.92" Width="699.3" Height="56.7" ManualBuildEvent="Table1_ManualBuild">
- <TableColumn Name="Column1" Width="431.55"/>
- <TableColumn Name="Column2" Width="110.25"/>
- <TableColumn Name="Column3" Width="157.5"/>
- <TableRow Name="Row1">
- <TableCell Name="Cell1" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="Product name" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
- <TableCell Name="Cell2" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="Unit price" Padding="0, 0, 5, 0" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
- <TableCell Name="Cell3" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="Units in stock" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
- </TableRow>
- <TableRow Name="Row2">
- <TableCell Name="Cell6" Border.Lines="All" Border.Color="LightGray" Text="[Products.ProductName]" Padding="5, 0, 0, 0" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TableCell Name="Cell7" Border.Lines="All" Border.Color="LightGray" Text="[Products.UnitPrice]" Padding="0, 0, 5, 0" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TableCell Name="Cell8" Border.Lines="All" Border.Color="LightGray" Text="[Products.UnitsInStock]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt"/>
- </TableRow>
- <TableRow Name="Row3">
- <TableCell Name="Cell11" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TableCell Name="Cell12" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="Total:" Padding="0, 0, 5, 0" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
- <TableCell Name="Cell13" Border.Lines="All" Border.Color="LightGray" Fill.Color="130, 180, 130" Text="[Sum(Cell8)]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
- </TableRow>
- </TableObject>
- </DataBand>
- <PageFooterBand Name="PageFooter1" Top="195.47" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke">
- <TextObject Name="Text1" Left="614.25" Width="94.5" Height="28.35" Text="[PageN]" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TextObject Name="Text12" Left="9.45" Width="217.35" Height="28.35" Cursor="Hand" Hyperlink.Value="https://www.fast-report.com/en/product/fast-report-net/" Text="Generated by FastReport" VertAlign="Center" Font="Segoe UI, 9pt, style=Underline" TextFill.Color="Blue"/>
- </PageFooterBand>
- </ReportPage>
- </Report>
|