123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?xml version="1.0" encoding="utf-8"?>
- <Report ScriptLanguage="CSharp" ReportInfo.Description="Demonstrates how to print other objects inside the matrix. In this example each data cell has an indicator which is red if value < 100; yellow if value < 3000; or green if value >= 3000. To do this: - create a matrix; - put three Shape objects inside the data cell; - increase the cell's width to contain both text and indicator. To do this, select the cell, go to Properties window and set the Padding.Left property to 50; - in the same window, click "Events" button and create a "BeforePrint" event handler; - in the handler, set the shapes' visibility and color based on the cell's Value. See the handler code for more details." ReportInfo.Created="05/16/2008 01:44:40" ReportInfo.Modified="03/30/2023 01:18:19" 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 Cell4_BeforePrint(object sender, EventArgs e)
- {
- // cast the cell's value to decimal because [MatrixDemo.Revenue]
- // data column is of System.Decimal type
- decimal value = Cell4.Value == null ? 0 : (decimal)Cell4.Value;
-
- // set shapes visibility: one shape if value < 100; two if < 3000; three if >= 3000
- Shape1.Visible = true;
- Shape2.Visible = value >= 100;
- Shape3.Visible = value >= 3000;
-
- // Highlight: red < 100; yellow < 3000; green >= 3000
- Color color = Color.Red;
- if (value >= 100)
- color = Color.Yellow;
- if (value >= 3000)
- color = Color.GreenYellow;
-
- Shape1.Fill = new SolidFill(color);
- Shape2.Fill = new SolidFill(color);
- Shape3.Fill = new SolidFill(color);
- }
- }
- }
- </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" RawPaperSize="9" Watermark.Font="Arial, 60pt">
- <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="56.7" CanGrow="true">
- <TextObject Name="Text1" Top="37.8" Width="718.2" Height="18.9" Text="Highlight: red < 100; yellow < 3000; green >= 3000" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt"/>
- <TextObject Name="Text13" Width="718.2" Height="37.8" Text="REVENUE BY EMPLOYEE" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
- </ReportTitleBand>
- <DataBand Name="Data1" Top="58.7" Width="718.2" Height="80.28">
- <MatrixObject Name="Matrix1" Top="9.45" Width="199.66" Height="61.38" FixedRows="1" FixedColumns="1" DataSource="MatrixDemo" Style="BlueWhite">
- <MatrixColumns>
- <Header Expression="[MatrixDemo.Year]"/>
- </MatrixColumns>
- <MatrixRows>
- <Header Expression="[MatrixDemo.Name]"/>
- </MatrixRows>
- <MatrixCells>
- <Cell Expression="[MatrixDemo.Revenue]"/>
- </MatrixCells>
- <TableColumn Name="Column1" Width="62.31" AutoSize="true"/>
- <TableColumn Name="Column2" Width="101.16" AutoSize="true"/>
- <TableColumn Name="Column3" Width="36.19" AutoSize="true"/>
- <TableRow Name="Row1" Height="20.46" AutoSize="true">
- <TableCell Name="Cell1" Border.Lines="All" Border.Color="White" Fill.Color="110, 145, 190" Text="Employee" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell2" Border.Lines="All" Border.Color="White" Fill.Color="110, 145, 190" Text="[Year]" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell7" Border.Lines="All" Border.Color="White" Fill.Color="110, 145, 190" Text="Total" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- </TableRow>
- <TableRow Name="Row2" Height="20.46" AutoSize="true">
- <TableCell Name="Cell3" Border.Lines="All" Border.Color="White" Fill.Color="110, 145, 190" Text="[Name]" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell4" Border.Lines="All" Border.Color="White" Fill.Color="WhiteSmoke" BeforePrintEvent="Cell4_BeforePrint" Text="[Revenue]" Padding="40, 1, 2, 1" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Segoe UI, 9pt">
- <ShapeObject Name="Shape1" Left="4" Top="5.67" Width="9.45" Height="9.45" Border.Color="White" Fill.Color="GreenYellow"/>
- <ShapeObject Name="Shape2" Left="13.45" Top="5.67" Width="9.45" Height="9.45" Border.Color="White" Fill.Color="GreenYellow"/>
- <ShapeObject Name="Shape3" Left="22.9" Top="5.67" Width="9.45" Height="9.45" Border.Color="White" Fill.Color="GreenYellow"/>
- </TableCell>
- <TableCell Name="Cell8" 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="Row4" Height="20.46" AutoSize="true">
- <TableCell Name="Cell5" Border.Lines="All" Border.Color="White" Fill.Color="110, 145, 190" Text="Total" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 9pt" TextFill.Color="White"/>
- <TableCell Name="Cell6" 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="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"/>
- </TableRow>
- </MatrixObject>
- </DataBand>
- <PageFooterBand Name="PageFooter1" Top="140.98" Width="718.2" 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>
|