1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?xml version="1.0" encoding="utf-8"?>
- <Report ScriptLanguage="CSharp" ReportInfo.Description="Demonstrates how to print month names instead of month numbers. To do this: - select the matrix item that contains the month data column; - go to the Properties window, click the "Events" button and create an event handler for the "BeforePrint" event; - in the event handler, set the cell's Text based on cell's Value. See this example's event handler for details." ReportInfo.Created="05/16/2008 01:44:40" ReportInfo.Modified="03/30/2023 01:14:17" 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 string[] monthNames = new string[] {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
- private void Cell4_BeforePrint(object sender, EventArgs e)
- {
- // Cell4.Value is the month number. This property is of System.Object type,
- // so we have to typecast to int.
- Cell4.Text = monthNames[(int)Cell4.Value - 1];
- }
- }
- }
- </ScriptText>
- <Dictionary>
- <TableDataSource Name="MatrixDemo" ReferenceName="NorthWind.MatrixDemo" DataType="System.Int32" Enabled="true">
- <Column Name="Name" DataType="System.String"/>
- <Column Name="Year" DataType="System.Int32"/>
- <Column Name="Month" DataType="System.Int32"/>
- <Column Name="ItemsSold" DataType="System.Int32"/>
- <Column Name="Revenue" DataType="System.Decimal"/>
- </TableDataSource>
- </Dictionary>
- <ReportPage Name="Page1" Landscape="true" PaperWidth="297" PaperHeight="210" RawPaperSize="9" Watermark.Font="Arial, 60pt">
- <ReportTitleBand Name="ReportTitle1" Width="1047.06" Height="37.8" CanGrow="true">
- <TextObject Name="Text1" Width="1048.95" Height="37.8" Text="REVENUE BY EMPLOYEE" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
- </ReportTitleBand>
- <DataBand Name="Data1" Top="39.8" Width="1047.06" Height="96.42">
- <MatrixObject Name="Matrix1" Top="5.13" Width="187.23" Height="81.84" FixedRows="2" FixedColumns="1" DataSource="MatrixDemo" Style="Orange">
- <MatrixColumns>
- <Header Expression="[MatrixDemo.Year]"/>
- <Header Expression="[MatrixDemo.Month]"/>
- </MatrixColumns>
- <MatrixRows>
- <Header Expression="[MatrixDemo.Name]"/>
- </MatrixRows>
- <MatrixCells>
- <Cell Expression="[MatrixDemo.Revenue]"/>
- </MatrixCells>
- <TableColumn Name="Column1" Width="49.11" AutoSize="true"/>
- <TableColumn Name="Column2" Width="63.16" AutoSize="true"/>
- <TableColumn Name="Column3" Width="36.19" AutoSize="true"/>
- <TableColumn Name="Column4" Width="38.77" AutoSize="true"/>
- <TableRow Name="Row1" Height="20.46" AutoSize="true">
- <TableCell Name="Cell1" Border.Lines="All" Border.Color="White" Fill.Color="160, 120, 160" Text="Name" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White" RowSpan="2"/>
- <TableCell Name="Cell2" Border.Lines="All" Border.Color="White" Fill.Color="160, 120, 160" Text="[Year]" AllowExpressions="false" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White" ColSpan="2"/>
- <TableCell Name="Cell7" Fill.Color="160, 120, 160" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell10" Border.Lines="All" Border.Color="White" Fill.Color="160, 120, 160" Text="Total" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold" TextFill.Color="White" RowSpan="2"/>
- </TableRow>
- <TableRow Name="Row2" Height="20.46" AutoSize="true">
- <TableCell Name="Cell3" Fill.Color="160, 120, 160" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell4" Border.Lines="All" Border.Color="White" Fill.Color="160, 120, 160" BeforePrintEvent="Cell4_BeforePrint" Text="[Month]" AllowExpressions="false" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell8" Border.Lines="All" Border.Color="White" Fill.Color="160, 120, 160" Text="Total" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell11" Fill.Color="160, 120, 160" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- </TableRow>
- <TableRow Name="Row5" Height="20.46" AutoSize="true">
- <TableCell Name="Cell5" Border.Lines="All" Border.Color="White" Fill.Color="160, 120, 160" Text="[Name]" AllowExpressions="false" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell6" Border.Lines="All" Border.Color="White" Fill.Color="WhiteSmoke" Text="[Revenue]" AllowExpressions="false" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TableCell Name="Cell9" Border.Lines="All" Border.Color="White" Fill.Color="WhiteSmoke" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TableCell Name="Cell12" Border.Lines="All" Border.Color="White" Fill.Color="WhiteSmoke" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- </TableRow>
- <TableRow Name="Row6" Height="20.46" AutoSize="true">
- <TableCell Name="Cell13" Border.Lines="All" Border.Color="White" Fill.Color="160, 120, 160" Text="Total" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold" TextFill.Color="White"/>
- <TableCell Name="Cell14" Border.Lines="All" Border.Color="White" Fill.Color="WhiteSmoke" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TableCell Name="Cell15" Border.Lines="All" Border.Color="White" Fill.Color="WhiteSmoke" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TableCell Name="Cell16" Border.Lines="All" Border.Color="White" Fill.Color="WhiteSmoke" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt, style=Bold"/>
- </TableRow>
- </MatrixObject>
- </DataBand>
- <PageFooterBand Name="PageFooter1" Top="138.22" Width="1047.06" Height="28.35" Fill.Color="WhiteSmoke">
- <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>
|