123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?xml version="1.0" encoding="utf-8"?>
- <Report ScriptLanguage="CSharp" ReportInfo.Description="This example demonstrates how to print a datasource using the TableObject. 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 TableObject.PrintRow method; in each row, you must also print all columns (using PrintColumn method). See the script's code for more details." ReportInfo.Created="08/01/2008 14:01:38" ReportInfo.Modified="04/07/2023 14:28:04" 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 "Customers" datasource
- DataSourceBase customers = Report.GetDataSource("Customers");
- // init it
- customers.Init();
-
- // number of columns in the datasource
- int colCount = customers.Columns.Count;
-
- // print the table header which contains column titles. It's a row with index = 0.
- Table1.PrintRow(0);
- for (int i = 0; i < colCount; i++)
- {
- // fill the cell with column title
- Cell1.Text = customers.Columns[i].Alias;
- // print it
- Table1.PrintColumn(0);
- }
-
- // now print a datasource content
- while (customers.HasMoreRows)
- {
- // print the table body. It's a row with index = 1.
- Table1.PrintRow(1);
- for (int i = 0; i < colCount; i++)
- {
- // fill the cell with datasource column's data
- Cell2.Text = customers[customers.Columns[i]].ToString();
- // print it
- Table1.PrintColumn(0);
- }
-
- // move to the next row
- customers.Next();
- }
- }
- }
- }
- </ScriptText>
- <Dictionary>
- <TableDataSource Name="Customers" ReferenceName="NorthWind.Customers" DataType="System.Int32" Enabled="true">
- <Column Name="CustomerID" DataType="System.String"/>
- <Column Name="CompanyName" DataType="System.String"/>
- <Column Name="ContactName" DataType="System.String"/>
- <Column Name="ContactTitle" DataType="System.String"/>
- <Column Name="Address" DataType="System.String"/>
- <Column Name="City" DataType="System.String"/>
- <Column Name="Region" DataType="System.String"/>
- <Column Name="PostalCode" DataType="System.String"/>
- <Column Name="Country" DataType="System.String"/>
- <Column Name="Phone" DataType="System.String"/>
- <Column Name="Fax" DataType="System.String"/>
- </TableDataSource>
- </Dictionary>
- <ReportPage Name="Page1" Landscape="true" PaperWidth="297" PaperHeight="210" RawPaperSize="9" Watermark.Font="Arial, 60pt" LastPageSource="15" FirstPageSource="15">
- <ReportTitleBand Name="ReportTitle1" Width="1047.06" Height="47.25" CanGrow="true">
- <TextObject Name="Text1" Width="1048.95" Height="37.8" Text="CUSTOMERS TABLE" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
- </ReportTitleBand>
- <DataBand Name="Data1" Top="49.25" Width="1047.06" Height="59.23">
- <TableObject Name="Table1" Width="94.5" Height="47.25" FixedRows="1" ManualBuildEvent="Table1_ManualBuild">
- <TableColumn Name="Column1" Width="94.5" AutoSize="true"/>
- <TableRow Name="Row1" Height="28.35">
- <TableCell Name="Cell1" Border.Lines="All" Border.Color="White" Fill.Color="110, 145, 190" Text="Title" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold" TextFill.Color="White"/>
- </TableRow>
- <TableRow Name="Row2" AutoSize="true">
- <TableCell Name="Cell2" Border.Lines="All" Border.Color="WhiteSmoke" Text="Data" VertAlign="Center" Font="Segoe UI, 9pt"/>
- </TableRow>
- </TableObject>
- </DataBand>
- <PageFooterBand Name="PageFooter1" Top="110.48" Width="1047.06" Height="28.35" Fill.Color="WhiteSmoke">
- <TextObject Name="Text12" 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>
|