Print Month Names.frx 7.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Report ScriptLanguage="CSharp" ReportInfo.Description="Demonstrates how to print month names instead of month numbers. To do this:&#13;&#10;- select the matrix item that contains the month data column;&#13;&#10;- go to the Properties window, click the &quot;Events&quot; button and create an event handler for the &quot;BeforePrint&quot; event;&#13;&#10;- 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">
  3. <ScriptText>using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Windows.Forms;
  8. using System.Drawing;
  9. using System.Data;
  10. using FastReport;
  11. using FastReport.Data;
  12. using FastReport.Dialog;
  13. using FastReport.Barcode;
  14. using FastReport.Table;
  15. using FastReport.Utils;
  16. namespace FastReport
  17. {
  18. public class ReportScript
  19. {
  20. private string[] monthNames = new string[] {
  21. &quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;, &quot;Jun&quot;, &quot;Jul&quot;, &quot;Aug&quot;, &quot;Sep&quot;, &quot;Oct&quot;, &quot;Nov&quot;, &quot;Dec&quot; };
  22. private void Cell4_BeforePrint(object sender, EventArgs e)
  23. {
  24. // Cell4.Value is the month number. This property is of System.Object type,
  25. // so we have to typecast to int.
  26. Cell4.Text = monthNames[(int)Cell4.Value - 1];
  27. }
  28. }
  29. }
  30. </ScriptText>
  31. <Dictionary>
  32. <TableDataSource Name="MatrixDemo" ReferenceName="NorthWind.MatrixDemo" DataType="System.Int32" Enabled="true">
  33. <Column Name="Name" DataType="System.String"/>
  34. <Column Name="Year" DataType="System.Int32"/>
  35. <Column Name="Month" DataType="System.Int32"/>
  36. <Column Name="ItemsSold" DataType="System.Int32"/>
  37. <Column Name="Revenue" DataType="System.Decimal"/>
  38. </TableDataSource>
  39. </Dictionary>
  40. <ReportPage Name="Page1" Landscape="true" PaperWidth="297" PaperHeight="210" RawPaperSize="9" Watermark.Font="Arial, 60pt">
  41. <ReportTitleBand Name="ReportTitle1" Width="1047.06" Height="37.8" CanGrow="true">
  42. <TextObject Name="Text1" Width="1048.95" Height="37.8" Text="REVENUE BY EMPLOYEE" HorzAlign="Center" VertAlign="Center" Font="Segoe UI, 14pt, style=Bold"/>
  43. </ReportTitleBand>
  44. <DataBand Name="Data1" Top="39.8" Width="1047.06" Height="96.42">
  45. <MatrixObject Name="Matrix1" Top="5.13" Width="187.23" Height="81.84" FixedRows="2" FixedColumns="1" DataSource="MatrixDemo" Style="Orange">
  46. <MatrixColumns>
  47. <Header Expression="[MatrixDemo.Year]"/>
  48. <Header Expression="[MatrixDemo.Month]"/>
  49. </MatrixColumns>
  50. <MatrixRows>
  51. <Header Expression="[MatrixDemo.Name]"/>
  52. </MatrixRows>
  53. <MatrixCells>
  54. <Cell Expression="[MatrixDemo.Revenue]"/>
  55. </MatrixCells>
  56. <TableColumn Name="Column1" Width="49.11" AutoSize="true"/>
  57. <TableColumn Name="Column2" Width="63.16" AutoSize="true"/>
  58. <TableColumn Name="Column3" Width="36.19" AutoSize="true"/>
  59. <TableColumn Name="Column4" Width="38.77" AutoSize="true"/>
  60. <TableRow Name="Row1" Height="20.46" AutoSize="true">
  61. <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"/>
  62. <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"/>
  63. <TableCell Name="Cell7" Fill.Color="160, 120, 160" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  64. <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"/>
  65. </TableRow>
  66. <TableRow Name="Row2" Height="20.46" AutoSize="true">
  67. <TableCell Name="Cell3" Fill.Color="160, 120, 160" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  68. <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"/>
  69. <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"/>
  70. <TableCell Name="Cell11" Fill.Color="160, 120, 160" Font="Segoe UI, 9pt" TextFill.Color="White"/>
  71. </TableRow>
  72. <TableRow Name="Row5" Height="20.46" AutoSize="true">
  73. <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"/>
  74. <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"/>
  75. <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"/>
  76. <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"/>
  77. </TableRow>
  78. <TableRow Name="Row6" Height="20.46" AutoSize="true">
  79. <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"/>
  80. <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"/>
  81. <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"/>
  82. <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"/>
  83. </TableRow>
  84. </MatrixObject>
  85. </DataBand>
  86. <PageFooterBand Name="PageFooter1" Top="138.22" Width="1047.06" Height="28.35" Fill.Color="WhiteSmoke">
  87. <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"/>
  88. </PageFooterBand>
  89. </ReportPage>
  90. </Report>