翻譯|行業資訊|編輯:胡濤|2024-04-17 10:56:49.763|閱讀 115 次
概述:新事件 PageCreate 在 FastReport .NET 引擎中創建新頁面時發生。在此階段,您可以更改頁面的屬性。 StartPage、FinishPage 和 ManualBuild 等其他事件在構建頁面模板開始/結束之前觸發。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
FastReport Business Graphics .NET,是一款基于fastreport報表開發控件的商業圖形庫,借助 FastReport 商業圖形庫,您可以可視化不同的分層數據,構建業務圖表以進行進一步分析和決策。利用數據呈現領域專家針對 .NET 7、.NET Core、Blazor、ASP.NET、MVC、Windows Forms 和 Mono 提供的完整的產品
FastReport .NET 是適用于.NET Core 3,ASP.NET,MVC和Windows窗體的全功能報告庫。使用FastReport .NET,您可以創建獨立于應用程序的.NET報告。
新事件 PageCreate 在 FastReport .NET 引擎中創建新頁面時發生。在此階段,您可以更改頁面的屬性。 StartPage、FinishPage 和 ManualBuild 等其他事件在構建頁面模板開始/結束之前觸發。
例如,您可以在橫向和縱向頁面方向之間交替。或者,借助此事件,您可以創建一個單獨的數據源,其中包含有關 ExportAlias 或其他頁面屬性的信息。在事件執行過程中,您可以設置參數,并在下一頁的開頭迭代數據源。
以下示例描述了使用 PageCreate 事件定義 ExportAlias 的修改后的演示報告。
<?xml version="1.0" encoding="utf-8"?> <Report ScriptLanguage="CSharp" TextQuality="Regular" ReportInfo.Description="Demonstrates a group report. To create it: - go to "Report|Configure Bands..." menu; - press "Add" button and add a group header (this will add a data band and a group footer as well); - return to the report page, doubleclick the group header to show its editor." ReportInfo.Created="01/17/2008 04:31:41" ReportInfo.Modified="03/13/2024 17:32:59" 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 Page1_CreatePage(object sender, EventArgs e) { if(Data1.DataSource.RowCount == 0) Data1.InitDataSource(); Page1.ExportAlias = Data1.DataSource["ProductName"].ToString().Substring(0,1); } } } </ScriptText> <Styles> <Style Name="EvenRows" Fill.Color="OldLace" Font="Arial, 10pt"/> </Styles> <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> <Total Name="TotalProducts" TotalType="Count" Evaluator="Data1" PrintOn="GroupFooter1"/> </Dictionary> <ReportPage Name="Page1" Watermark.Font="Arial, 60pt" CreatePageEvent="Page1_CreatePage"> <ReportTitleBand Name="ReportTitle1" Width="718.2" Height="103.95" CanGrow="true"> <TextObject Name="Text1" Top="56.7" Width="718.2" Height="47.25" Text="ALPHABETICAL PRODUCT LIST" HorzAlign="Center" VertAlign="Center" Font="Tahoma, 14pt, style=Bold"/> <TextObject Name="Text11" Top="28.35" Width="718.2" Height="28.35" Anchor="Top, Left, Right" Fill.Color="WhiteSmoke" CanGrow="true" CanShrink="true" Text="[Report.ReportInfo.Description] " Padding="4, 4, 4, 4" Font="Tahoma, 8pt"/> <TextObject Name="Text18" Width="718.2" Height="28.35" Anchor="Top, Left, Right" Fill.Color="WhiteSmoke" Cursor="Hand" Hyperlink.Value="http://fast.report/cda2a" Hyperlink.OpenLinkInNewTab="true" Text="Learn how to build this report on the Fast Reports Academy channel" VertAlign="Center" Font="Tahoma, 10pt, style=Bold, Underline" TextFill.Color="Blue"/> </ReportTitleBand> <GroupHeaderBand Name="GroupHeader1" Top="107.15" Width="718.2" Height="37.8" StartNewPage="true" KeepWithData="true" Condition="[Products.ProductName].Substring(0,1)" SortOrder="None"> <TextObject Name="Text7" Left="9.45" Width="699.3" Height="37.8" Border.Lines="All" Border.Color="LightSkyBlue" Fill="LinearGradient" Fill.StartColor="LightSkyBlue" Fill.EndColor="AliceBlue" Fill.Angle="90" Fill.Focus="0.42" Fill.Contrast="1" Text="[[Products.ProductName].Substring(0,1)]" Padding="5, 0, 0, 0" VertAlign="Center" Font="Tahoma, 12pt, style=Bold"/> <DataBand Name="Data1" Top="148.15" Width="718.2" Height="18.9" DataSource="Products" KeepTogether="true"> <TextObject Name="Text2" Left="9.45" Width="604.8" Height="18.9" Border.Lines="Left" Border.Color="LightSkyBlue" Text="[Products.ProductName]" VertAlign="Center" Font="Tahoma, 8pt"> <Highlight> <Condition Expression="[Row#] % 2 == 0" Fill.Color="AliceBlue" TextFill.Color="Black" Font="Arial, 10pt" ApplyFill="true" ApplyTextFill="false"/> </Highlight> </TextObject> <TextObject Name="Text4" Left="614.25" Width="94.5" Height="18.9" Border.Lines="Right" Border.Color="LightSkyBlue" Text="[Products.UnitPrice]" Format="Currency" Format.UseLocale="true" Format.DecimalDigits="2" HorzAlign="Right" VertAlign="Center" Font="Tahoma, 8pt"> <Highlight> <Condition Expression="[Row#] % 2 == 0" Fill.Color="AliceBlue" TextFill.Color="Black" Font="Arial, 10pt" ApplyFill="true" ApplyTextFill="false"/> </Highlight> </TextObject> <Sort> <Sort Expression="[Products.ProductName]"/> </Sort> </DataBand> <GroupFooterBand Name="GroupFooter1" Top="170.25" Width="718.2" Height="47.25" KeepWithData="true"> <TextObject Name="Text8" Left="9.45" Width="699.3" Height="18.9" Border.Lines="Left, Right, Bottom" Border.Color="LightSkyBlue" Text="Total products: [TotalProducts]" HorzAlign="Right" VertAlign="Center" Font="Tahoma, 8pt, style=Bold"/> </GroupFooterBand> </GroupHeaderBand> <PageFooterBand Name="PageFooter1" Top="220.7" Width="718.2" Height="28.35" Fill.Color="WhiteSmoke"> <TextObject Name="Text9" Left="614.25" Width="94.5" Height="28.35" Text="[PageN]" HorzAlign="Right" VertAlign="Center" Font="Tahoma, 8pt"/> <TextObject Name="Text12" Left="9.45" Width="217.35" Height="28.35" Cursor="Hand" Hyperlink.Value="http://www.fast-report.com/en/product/fast-report-net/" Text="Generated by FastReport .NET" VertAlign="Center" Font="Tahoma, 8pt, style=Underline" TextFill.Color="Blue"/> </PageFooterBand> </ReportPage> </Report>
將示例中的報表導出到 Excel 2007 的結果:
注意 1.調用新事件后,Engine.CurPage 會增加,并且由于 CurPage 是頁面的索引,因此在創建前兩個頁面時,其值為 0。因此,我們建議在使用新事件時在報告腳本中使用單獨的頁面計數器。
注意 2.當將 Visible 屬性更改為 false 時,頁面的進一步構建將停止。
借助新屬性,您可以移動到新的數據記錄行并在添加新頁面時修改頁面屬性。
FastReport技術QQ群:585577353
了解更多報表開發控件,歡迎咨詢
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn