diff --git a/.gitignore b/.gitignore
index 220934cf..536db55f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -245,3 +245,4 @@ ModelManifest.xml
# FAKE - F# Make
.fake/
*.bak
+/Extras/ReportBuilder/.dotnet
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/FastReport.ReportBuilder.UnitTest.csproj b/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/FastReport.ReportBuilder.UnitTest.csproj
index 8c0a99fd..d017f3f3 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/FastReport.ReportBuilder.UnitTest.csproj
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/FastReport.ReportBuilder.UnitTest.csproj
@@ -1,99 +1,37 @@
-
-
-
-
+
+
- Debug
- AnyCPU
- {17CE85B1-B182-4BEA-90A8-F8D110B1CFCE}
- Library
- Properties
+ net48
+ true
+ false
+ false
FastReport.ReportBuilder.UnitTest
FastReport.ReportBuilder.UnitTest
- v4.7.1
- 512
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 15.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
- False
- UnitTest
-
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
+
-
-
- ..\..\..\packages\FastReport.OpenSource.2021.1.0\lib\net40\FastReport.dll
-
-
- ..\..\..\packages\FastReport.Compat.2020.4.2\lib\net40\FastReport.Compat.dll
-
-
- ..\..\..\packages\FastReport.OpenSource.Export.PdfSimple.2021.1.2\lib\net40\FastReport.OpenSource.Export.PdfSimple.dll
-
-
- ..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
+
+ true
-
- ..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
-
-
-
- ..\..\..\packages\System.ComponentModel.Annotations.4.1.0\lib\net461\System.ComponentModel.Annotations.dll
-
-
-
-
-
-
- ..\..\..\packages\System.Drawing.Common.4.5.1\lib\net461\System.Drawing.Common.dll
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
-
- {abfbdac5-ac9e-44b4-9201-fe8bfbd5db0a}
- FastReport.ReportBuilder
-
+
-
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
-
+
+
+
-
-
-
\ No newline at end of file
+
+
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/ReportTest.cs b/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/ReportTest.cs
index 89477989..3cc69d3c 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/ReportTest.cs
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/ReportTest.cs
@@ -1,7 +1,9 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FastReport.Export.PdfSimple;
+using FastReport.Utils;
using System.Drawing;
using System.Collections.Generic;
+using System.IO;
namespace FastReport.ReportBuilder.UnitTest
{
@@ -36,7 +38,7 @@ public void export_basic_report_pdf()
.Prepare();
PDFSimpleExport pdfExport = new PDFSimpleExport();
- pdfExport.Export(report, "Employees.pdf");
+ pdfExport.Export(report, "basic_report.pdf");
}
[TestMethod]
@@ -58,7 +60,7 @@ public void export_report_resized_columns_by_percentage_pdf()
.Prepare();
PDFSimpleExport pdfExport = new PDFSimpleExport();
- pdfExport.Export(report, "Employees.pdf");
+ pdfExport.Export(report, "report_resized_columns_by_percentage.pdf");
}
[TestMethod]
@@ -80,7 +82,7 @@ public void export_report_using_column_format_pdf()
.Prepare();
PDFSimpleExport pdfExport = new PDFSimpleExport();
- pdfExport.Export(report, "Employees.pdf");
+ pdfExport.Export(report, "report_using_column_format.pdf");
}
[TestMethod]
@@ -102,7 +104,7 @@ public void export_report_using_expression_pdf()
.Prepare();
PDFSimpleExport pdfExport = new PDFSimpleExport();
- pdfExport.Export(report, "Employees.pdf");
+ pdfExport.Export(report, "report_using_expression.pdf");
}
[TestMethod]
@@ -133,7 +135,147 @@ public void export_group_report_pdf()
.Prepare();
PDFSimpleExport pdfExport = new PDFSimpleExport();
- pdfExport.Export(report, "Employees.pdf");
+ pdfExport.Export(report, "group_report.pdf");
+ }
+
+ [TestMethod]
+ public void prepare_report_with_page_configuration_and_extra_bands()
+ {
+ var report = builder.Report(list)
+ .ReportTitle(t => t
+ .Text("Employee List")
+ .HorzAlign(HorzAlign.Center)
+ )
+ .Landscape()
+ .PaperSize(210, 297)
+ .Margins(15, 20, 15, 20)
+ .PageHeader(header => header
+ .Text("Employees")
+ .HorzAlign(HorzAlign.Center)
+ .Height(0.7f))
+ .DataHeader(header => header
+ .TextColor(Color.DarkBlue)
+ .FillColor(Color.LightGray))
+ .PageFooter(footer => footer
+ .Text("Page [Page#] of [TotalPages#]")
+ .HorzAlign(HorzAlign.Right)
+ .Height(0.7f))
+ .ReportSummary(summary => summary
+ .Text("Report completed")
+ .Height(0.7f))
+ .Data(data =>
+ {
+ data.Column(col => col.FirstName);
+ data.Column(col => col.LastName);
+ })
+ .Prepare();
+
+ PDFSimpleExport pdfExport = new PDFSimpleExport();
+ pdfExport.Export(report, "report_with_page_configuration_and_extra_bands.pdf");
+
+ var page = (ReportPage)report.Pages[0];
+ var headerText = (TextObject)page.PageHeader.Objects[0];
+ var footerText = (TextObject)page.PageFooter.Objects[0];
+ var summaryText = (TextObject)page.ReportSummary.Objects[0];
+
+ Assert.IsTrue(page.Landscape);
+ Assert.AreEqual(210f, page.PaperWidth, 0.001f);
+ Assert.AreEqual(297f, page.PaperHeight, 0.001f);
+ Assert.AreEqual(15f, page.LeftMargin, 0.001f);
+ Assert.AreEqual(20f, page.TopMargin, 0.001f);
+ Assert.AreEqual(15f, page.RightMargin, 0.001f);
+ Assert.AreEqual(20f, page.BottomMargin, 0.001f);
+ Assert.AreEqual("Employees", headerText.Text);
+ Assert.AreEqual(HorzAlign.Center, headerText.HorzAlign);
+ Assert.AreEqual("Page [Page#] of [TotalPages#]", footerText.Text);
+ Assert.AreEqual(HorzAlign.Right, footerText.HorzAlign);
+ Assert.AreEqual("Report completed", summaryText.Text);
+ Assert.IsTrue(File.Exists("report_with_page_configuration_and_extra_bands.pdf"));
+ }
+
+ [TestMethod]
+ public void prepare_report_title_horz_align_is_applied()
+ {
+ var report = builder.Report(list)
+ .ReportTitle(t => t
+ .Text("Employee List")
+ .HorzAlign(HorzAlign.Right)
+ )
+ .Data(data =>
+ {
+ data.Column(col => col.FirstName);
+ data.Column(col => col.LastName);
+ })
+ .Prepare();
+
+ var page = (ReportPage)report.Pages[0];
+ var titleText = (TextObject)page.ReportTitle.Objects[0];
+
+ Assert.AreEqual(HorzAlign.Right, titleText.HorzAlign);
+ }
+
+ [TestMethod]
+ public void prepare_report_title_height_is_applied()
+ {
+ var report = builder.Report(list)
+ .ReportTitle(t => t
+ .Text("Employee List")
+ .Height(2.0f)
+ )
+ .Data(data =>
+ {
+ data.Column(col => col.FirstName);
+ data.Column(col => col.LastName);
+ })
+ .Prepare();
+
+ var page = (ReportPage)report.Pages[0];
+
+ Assert.AreEqual(Units.Centimeters * 2.0f, page.ReportTitle.Height, 0.001f);
+ }
+
+ [TestMethod]
+ public void prepare_data_header_fill_and_text_color_are_applied()
+ {
+ var report = builder.Report(list)
+ .DataHeader(header => header
+ .FillColor(Color.LightBlue)
+ .TextColor(Color.DarkRed)
+ )
+ .Data(data =>
+ {
+ data.Column(col => col.FirstName);
+ data.Column(col => col.LastName);
+ })
+ .Prepare();
+
+ var page = (ReportPage)report.Pages[0];
+ var dataBand = (DataBand)page.Bands[0];
+ var dataHeader = (DataHeaderBand)dataBand.Header;
+ var headerCell = (TextObject)dataHeader.Objects[0];
+
+ Assert.AreEqual(Color.LightBlue, headerCell.FillColor);
+ Assert.AreEqual(Color.DarkRed, headerCell.TextColor);
+ }
+
+ [TestMethod]
+ public void prepare_report_level_horz_align_propagates_to_data_header_cells()
+ {
+ var report = builder.Report(list)
+ .HorzAlign(HorzAlign.Center)
+ .Data(data =>
+ {
+ data.Column(col => col.FirstName);
+ data.Column(col => col.LastName);
+ })
+ .Prepare();
+
+ var page = (ReportPage)report.Pages[0];
+ var dataBand = (DataBand)page.Bands[0];
+ var dataHeader = (DataHeaderBand)dataBand.Header;
+ var headerCell = (TextObject)dataHeader.Objects[0];
+
+ Assert.AreEqual(HorzAlign.Center, headerCell.HorzAlign);
}
}
}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/packages.config b/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/packages.config
deleted file mode 100644
index 954ce7c2..00000000
--- a/Extras/ReportBuilder/FastReport.ReportBuilder.UnitTest/packages.config
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/PageFooterBuilder.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/PageFooterBuilder.cs
new file mode 100644
index 00000000..579222d7
--- /dev/null
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/PageFooterBuilder.cs
@@ -0,0 +1,18 @@
+namespace FastReport.ReportBuilder
+{
+ ///
+ /// Configures the page footer band.
+ ///
+ /// The report row type.
+ public class PageFooterBuilder : TextBandBuilderBase, T>
+ {
+ ///
+ /// Initializes a page footer builder.
+ ///
+ /// The owning report builder.
+ public PageFooterBuilder(ReportBuilder report)
+ : base(report, report._pageFooter)
+ {
+ }
+ }
+}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/PageHeaderBuilder.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/PageHeaderBuilder.cs
new file mode 100644
index 00000000..18af13ab
--- /dev/null
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/PageHeaderBuilder.cs
@@ -0,0 +1,18 @@
+namespace FastReport.ReportBuilder
+{
+ ///
+ /// Configures the page header band.
+ ///
+ /// The report row type.
+ public class PageHeaderBuilder : TextBandBuilderBase, T>
+ {
+ ///
+ /// Initializes a page header builder.
+ ///
+ /// The owning report builder.
+ public PageHeaderBuilder(ReportBuilder report)
+ : base(report, report._pageHeader)
+ {
+ }
+ }
+}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportBuilder.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportBuilder.cs
index 7d340991..caa51ccf 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportBuilder.cs
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportBuilder.cs
@@ -1,12 +1,11 @@
-using FastReport;
-using System;
+using System;
using System.Collections.Generic;
using System.Drawing;
namespace FastReport.ReportBuilder
{
///
- ///
+ /// Configures a report definition for a specific data source type.
///
///
public class ReportBuilder
@@ -16,9 +15,16 @@ public class ReportBuilder
internal DataHeaderDefinition _dataHeader = new DataHeaderDefinition();
internal ReportDefinition _report = new ReportDefinition();
internal ReportTitleDefinition _reportTitle = new ReportTitleDefinition();
+ internal TextBandDefinition _pageHeader = new TextBandDefinition();
+ internal TextBandDefinition _pageFooter = new TextBandDefinition();
+ internal TextBandDefinition _reportSummary = new TextBandDefinition();
internal GroupHeaderDefinition _groupHeader = new GroupHeaderDefinition();
internal GroupHeaderDefinition _groupFooter = new GroupHeaderDefinition();
+ ///
+ /// Initializes a new report builder for the provided data source.
+ ///
+ /// The records that will be registered with the FastReport data source.
public ReportBuilder(IEnumerable data)
{
_data = data;
@@ -27,8 +33,8 @@ public ReportBuilder(IEnumerable data)
///
/// Add a report title band
///
- ///
- ///
+ /// The configuration callback used to customize the report title band.
+ /// The current report builder.
public ReportBuilder ReportTitle(Action> config)
{
var builder = new ReportTitleBuilder(this);
@@ -39,8 +45,8 @@ public ReportBuilder ReportTitle(Action> config)
///
/// Add a data header band
///
- ///
- ///
+ /// The configuration callback used to customize the data header band.
+ /// The current report builder.
public ReportBuilder DataHeader(Action> config)
{
var builder = new DataHeaderBuilder(this);
@@ -51,8 +57,8 @@ public ReportBuilder DataHeader(Action> config)
///
/// Add a data band with columns
///
- ///
- ///
+ /// The configuration callback used to define report columns.
+ /// The current report builder.
public ReportBuilder Data(Action> config)
{
var builder = new DataBuilder(this);
@@ -63,8 +69,8 @@ public ReportBuilder Data(Action> config)
///
/// Add a group header band for grouping rows
///
- ///
- ///
+ /// The configuration callback used to customize the group header band.
+ /// The current report builder.
public ReportBuilder GroupHeader(Action> config)
{
var builder = new GroupHeaderBuilder(this);
@@ -72,13 +78,49 @@ public ReportBuilder GroupHeader(Action> config)
return this;
}
+ ///
+ /// Add a page header band
+ ///
+ /// The configuration callback used to customize the page header band.
+ /// The current report builder.
+ public ReportBuilder PageHeader(Action> config)
+ {
+ var builder = new PageHeaderBuilder(this);
+ config(builder);
+ return this;
+ }
+
+ ///
+ /// Add a page footer band
+ ///
+ /// The configuration callback used to customize the page footer band.
+ /// The current report builder.
+ public ReportBuilder PageFooter(Action> config)
+ {
+ var builder = new PageFooterBuilder(this);
+ config(builder);
+ return this;
+ }
+
+ ///
+ /// Add a report summary band
+ ///
+ /// The configuration callback used to customize the report summary band.
+ /// The current report builder.
+ public ReportBuilder ReportSummary(Action> config)
+ {
+ var builder = new ReportSummaryBuilder(this);
+ config(builder);
+ return this;
+ }
+
///
/// Set report font family name, size, style
///
- ///
- ///
- ///
- ///
+ /// The font family name.
+ /// The font size in points.
+ /// The font style to apply.
+ /// The current report builder.
public ReportBuilder Font(string familyName, float emSize, FontStyle style)
{
_report.Font = new Font(familyName, emSize, style);
@@ -88,9 +130,9 @@ public ReportBuilder Font(string familyName, float emSize, FontStyle style)
///
/// Set report font family name, size
///
- ///
- ///
- ///
+ /// The font family name.
+ /// The font size in points.
+ /// The current report builder.
public ReportBuilder Font(string familyName, float emSize)
{
return Font(familyName, emSize, FontStyle.Regular);
@@ -99,8 +141,8 @@ public ReportBuilder Font(string familyName, float emSize)
///
/// Set report font family name
///
- ///
- ///
+ /// The font family name.
+ /// The current report builder.
public ReportBuilder Font(string familyName)
{
return Font(familyName, 10.0f, FontStyle.Regular);
@@ -109,8 +151,8 @@ public ReportBuilder Font(string familyName)
///
/// Align report content vertical top, bottom, center
///
- ///
- ///
+ /// The default vertical alignment for report text objects.
+ /// The current report builder.
public ReportBuilder VertAlign(VertAlign vertAlign)
{
_report.VertAlign = vertAlign;
@@ -120,12 +162,53 @@ public ReportBuilder VertAlign(VertAlign vertAlign)
///
/// Align report content horizontal left, right, center, justify
///
- ///
- ///
+ /// The default horizontal alignment for report text objects.
+ /// The current report builder.
public ReportBuilder HorzAlign(HorzAlign horzAlign)
{
_report.HorzAlign = horzAlign;
return this;
}
+
+ ///
+ /// Set page orientation
+ ///
+ /// to render the page in landscape orientation; otherwise, .
+ /// The current report builder.
+ public ReportBuilder Landscape(bool landscape = true)
+ {
+ _report.Landscape = landscape;
+ return this;
+ }
+
+ ///
+ /// Set page size in millimeters
+ ///
+ /// The paper width in millimeters.
+ /// The paper height in millimeters.
+ /// The current report builder.
+ public ReportBuilder PaperSize(float width, float height)
+ {
+ _report.PaperWidth = width;
+ _report.PaperHeight = height;
+ return this;
+ }
+
+ ///
+ /// Set page margins in millimeters
+ ///
+ /// The left margin in millimeters.
+ /// The top margin in millimeters.
+ /// The right margin in millimeters.
+ /// The bottom margin in millimeters.
+ /// The current report builder.
+ public ReportBuilder Margins(float left, float top, float right, float bottom)
+ {
+ _report.LeftMargin = left;
+ _report.TopMargin = top;
+ _report.RightMargin = right;
+ _report.BottomMargin = bottom;
+ return this;
+ }
}
}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportSummaryBuilder.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportSummaryBuilder.cs
new file mode 100644
index 00000000..ba127f0f
--- /dev/null
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportSummaryBuilder.cs
@@ -0,0 +1,18 @@
+namespace FastReport.ReportBuilder
+{
+ ///
+ /// Configures the report summary band.
+ ///
+ /// The report row type.
+ public class ReportSummaryBuilder : TextBandBuilderBase, T>
+ {
+ ///
+ /// Initializes a report summary builder.
+ ///
+ /// The owning report builder.
+ public ReportSummaryBuilder(ReportBuilder report)
+ : base(report, report._reportSummary)
+ {
+ }
+ }
+}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportTitleBuilder.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportTitleBuilder.cs
index fcca2816..e53c96ec 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportTitleBuilder.cs
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/ReportTitleBuilder.cs
@@ -1,124 +1,41 @@
-using FastReport;
using System.Drawing;
namespace FastReport.ReportBuilder
{
///
- ///
+ /// Configures the report title band.
///
- ///
- public class ReportTitleBuilder
+ /// The report row type.
+ public class ReportTitleBuilder : TextBandBuilderBase, T>
{
- private readonly ReportBuilder _report;
-
///
- ///
+ /// Initializes a report title builder.
///
- ///
+ /// The owning report builder.
public ReportTitleBuilder(ReportBuilder report)
+ : base(report, report._reportTitle)
{
- _report = report;
- }
-
- ///
- /// Report title text (or add an expression)
- ///
- ///
- ///
- public ReportTitleBuilder Text(string text)
- {
- _report._reportTitle.Text = text;
- _report._reportTitle.Visible = true;
- return this;
- }
-
- ///
- /// Set report title font family name, size, style
- ///
- ///
- ///
- ///
- ///
- public ReportTitleBuilder Font(string familyName, float emSize, FontStyle style)
- {
- _report._reportTitle.Font = new Font(familyName, emSize, style);
- return this;
}
///
- /// Set report title font family name, size
+ /// Sets the report title font family and size using the default bold title style.
///
- ///
- ///
- ///
- public ReportTitleBuilder Font(string familyName, float emSize)
+ /// The font family name.
+ /// The font size in points.
+ /// The current title builder.
+ public new ReportTitleBuilder Font(string familyName, float emSize)
{
return Font(familyName, emSize, FontStyle.Regular | FontStyle.Bold);
}
///
- /// Set report title font family name
+ /// Sets the report title font family using the default bold title size and style.
///
- ///
- ///
- public ReportTitleBuilder Font(string familyName)
+ /// The font family name.
+ /// The current title builder.
+ public new ReportTitleBuilder Font(string familyName)
{
return Font(familyName, 14, FontStyle.Regular | FontStyle.Bold);
}
-
- ///
- /// Set report title visibility
- ///
- ///
- ///
- public ReportTitleBuilder Visible(bool visible)
- {
- _report._reportTitle.Visible = visible;
- return this;
- }
-
- ///
- /// Set report title text color
- ///
- ///
- ///
- public ReportTitleBuilder TextColor(Color color)
- {
- _report._reportTitle.TextColor = color;
- return this;
- }
-
- ///
- /// Set report title background color
- ///
- ///
- ///
- public ReportTitleBuilder FillColor(Color color)
- {
- _report._reportTitle.FillColor = color;
- return this;
- }
-
- ///
- /// Align report title content vertical top, bottom, center
- ///
- ///
- ///
- public ReportTitleBuilder VertAlign(VertAlign vertAlign)
- {
- _report._reportTitle.VertAlign = vertAlign;
- return this;
- }
-
- ///
- /// Align report title content horizontal left, right, center, justify
- ///
- ///
- ///
- public ReportTitleBuilder HorzAlign(HorzAlign horzAlign)
- {
- _report._reportTitle.HorzAlign = horzAlign;
- return this;
- }
}
}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/TextBandBuilderBase.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/TextBandBuilderBase.cs
new file mode 100644
index 00000000..a7f47ba4
--- /dev/null
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Builders/TextBandBuilderBase.cs
@@ -0,0 +1,146 @@
+using System.Drawing;
+
+namespace FastReport.ReportBuilder
+{
+ ///
+ /// Provides shared fluent configuration for text-based report bands.
+ ///
+ /// The concrete builder type.
+ /// The report row type.
+ public abstract class TextBandBuilderBase
+ where TBuilder : TextBandBuilderBase
+ {
+ ///
+ /// The owning report builder.
+ ///
+ protected readonly ReportBuilder Report;
+
+ ///
+ /// The backing definition being configured by the fluent API.
+ ///
+ protected readonly TextBandDefinition Definition;
+
+ ///
+ /// Initializes a new text-band builder.
+ ///
+ /// The owning report builder.
+ /// The backing band definition to update.
+ protected TextBandBuilderBase(ReportBuilder report, TextBandDefinition definition)
+ {
+ Report = report;
+ Definition = definition;
+ }
+
+ ///
+ /// Sets the displayed text for the band.
+ ///
+ /// The text or expression to render.
+ /// The current band builder.
+ public TBuilder Text(string text)
+ {
+ Definition.Text = text;
+ Definition.Visible = true;
+ return (TBuilder)this;
+ }
+
+ ///
+ /// Sets the band font family, size, and style.
+ ///
+ /// The font family name.
+ /// The font size in points.
+ /// The font style to apply.
+ /// The current band builder.
+ public TBuilder Font(string familyName, float emSize, FontStyle style)
+ {
+ Definition.Font = new Font(familyName, emSize, style);
+ return (TBuilder)this;
+ }
+
+ ///
+ /// Sets the band font family and size.
+ ///
+ /// The font family name.
+ /// The font size in points.
+ /// The current band builder.
+ public TBuilder Font(string familyName, float emSize)
+ {
+ return Font(familyName, emSize, FontStyle.Regular);
+ }
+
+ ///
+ /// Sets the band font family using the default size and style.
+ ///
+ /// The font family name.
+ /// The current band builder.
+ public TBuilder Font(string familyName)
+ {
+ return Font(familyName, 10.0f, FontStyle.Regular);
+ }
+
+ ///
+ /// Sets whether the band is visible in the prepared report.
+ ///
+ /// to show the band; otherwise, .
+ /// The current band builder.
+ public TBuilder Visible(bool visible)
+ {
+ Definition.Visible = visible;
+ return (TBuilder)this;
+ }
+
+ ///
+ /// Sets the text color for the band.
+ ///
+ /// The text color.
+ /// The current band builder.
+ public TBuilder TextColor(Color color)
+ {
+ Definition.TextColor = color;
+ return (TBuilder)this;
+ }
+
+ ///
+ /// Sets the background fill color for the band.
+ ///
+ /// The fill color.
+ /// The current band builder.
+ public TBuilder FillColor(Color color)
+ {
+ Definition.FillColor = color;
+ return (TBuilder)this;
+ }
+
+ ///
+ /// Sets the vertical text alignment for the band.
+ ///
+ /// The vertical alignment.
+ /// The current band builder.
+ public TBuilder VertAlign(VertAlign vertAlign)
+ {
+ Definition.VertAlign = vertAlign;
+ return (TBuilder)this;
+ }
+
+ ///
+ /// Sets the horizontal text alignment for the band.
+ ///
+ /// The horizontal alignment.
+ /// The current band builder.
+ public TBuilder HorzAlign(HorzAlign horzAlign)
+ {
+ Definition.HorzAlign = horzAlign;
+ return (TBuilder)this;
+ }
+
+ ///
+ /// Sets the band height in centimeters.
+ ///
+ /// The desired band height in centimeters.
+ /// The current band builder.
+ public TBuilder Height(float centimeters)
+ {
+ Definition.Height = centimeters;
+ return (TBuilder)this;
+ }
+ }
+}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/DataDefinition.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/DataDefinition.cs
index 5b1fddbe..ef17e7a6 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/DataDefinition.cs
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/DataDefinition.cs
@@ -1,13 +1,43 @@
-namespace FastReport.ReportBuilder
+namespace FastReport.ReportBuilder
{
+ ///
+ /// Stores layout and formatting information for a data column.
+ ///
public class DataDefinition
{
+ ///
+ /// Gets or sets the displayed column title.
+ ///
public string Title { get; set; }
+
+ ///
+ /// Gets or sets the bound property name.
+ ///
public string Name { get; set; }
+
+ ///
+ /// Gets or sets the column width as a percentage value multiplied by ten.
+ ///
public uint Width { get; set; }
+
+ ///
+ /// Gets or sets the custom format string applied to the column value.
+ ///
public string Format { get; set; }
+
+ ///
+ /// Gets or sets the FastReport expression used to render the column value.
+ ///
public string Expression { get; set; }
+
+ ///
+ /// Gets or sets the column vertical alignment override.
+ ///
public VertAlign? VertAlign { get; set; }
+
+ ///
+ /// Gets or sets the column horizontal alignment override.
+ ///
public HorzAlign? HorzAlign { get; set; }
}
}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/DataHeaderDefinition.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/DataHeaderDefinition.cs
index 559db377..5c1eeef2 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/DataHeaderDefinition.cs
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/DataHeaderDefinition.cs
@@ -1,12 +1,30 @@
-using System.Drawing;
+using System.Drawing;
namespace FastReport.ReportBuilder
{
+ ///
+ /// Stores appearance settings for the data header band.
+ ///
public class DataHeaderDefinition
{
+ ///
+ /// Gets or sets the font used by header cells.
+ ///
public Font Font { get; set; } = new Font("Times New Roman", 10.0f, FontStyle.Regular);
+
+ ///
+ /// Gets or sets a value indicating whether the data header band is rendered.
+ ///
public bool Visible { get; set; } = true;
+
+ ///
+ /// Gets or sets the header text color.
+ ///
public Color TextColor { get; set; } = Color.Black;
+
+ ///
+ /// Gets or sets the header background fill color.
+ ///
public Color FillColor { get; set; } = Color.FromArgb(235, 243, 251);
}
}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/GroupHeaderDefinition.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/GroupHeaderDefinition.cs
index f00d2b06..4787bf9b 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/GroupHeaderDefinition.cs
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/GroupHeaderDefinition.cs
@@ -1,12 +1,38 @@
-namespace FastReport.ReportBuilder
+namespace FastReport.ReportBuilder
{
+ ///
+ /// Stores grouping settings for the group header band.
+ ///
public class GroupHeaderDefinition
{
+ ///
+ /// Gets or sets the property name used for grouping.
+ ///
public string Name { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether grouping is enabled.
+ ///
public bool Visible { get; set; }
+
+ ///
+ /// Gets or sets the sort order applied to grouped values.
+ ///
public SortOrder SortOrder { get; set; } = SortOrder.Ascending;
+
+ ///
+ /// Gets or sets an optional expression used to transform the group value.
+ ///
public string Expression { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether the group header text is shown.
+ ///
public bool TextVisible { get; set; } = true;
+
+ ///
+ /// Gets or sets the group header height in centimeters.
+ ///
public float Height { get; set; }
}
}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/ReportDefinition.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/ReportDefinition.cs
index 470ce02f..ac39ab9e 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/ReportDefinition.cs
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/ReportDefinition.cs
@@ -2,10 +2,59 @@
namespace FastReport.ReportBuilder
{
+ ///
+ /// Stores page-level report defaults and layout settings.
+ ///
public class ReportDefinition
{
+ ///
+ /// Gets or sets the default font for report text objects.
+ ///
public Font Font { get; set; } = new Font("Times New Roman", 10.0f, FontStyle.Regular);
+
+ ///
+ /// Gets or sets the default vertical alignment for report text objects.
+ ///
public VertAlign VertAlign { get; set; }
+
+ ///
+ /// Gets or sets the default horizontal alignment for report text objects.
+ ///
public HorzAlign HorzAlign { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether pages use landscape orientation.
+ ///
+ public bool Landscape { get; set; }
+
+ ///
+ /// Gets or sets the paper width in millimeters.
+ ///
+ public float? PaperWidth { get; set; }
+
+ ///
+ /// Gets or sets the paper height in millimeters.
+ ///
+ public float? PaperHeight { get; set; }
+
+ ///
+ /// Gets or sets the left margin in millimeters.
+ ///
+ public float LeftMargin { get; set; } = 10;
+
+ ///
+ /// Gets or sets the top margin in millimeters.
+ ///
+ public float TopMargin { get; set; } = 10;
+
+ ///
+ /// Gets or sets the right margin in millimeters.
+ ///
+ public float RightMargin { get; set; } = 10;
+
+ ///
+ /// Gets or sets the bottom margin in millimeters.
+ ///
+ public float BottomMargin { get; set; } = 10;
}
}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/ReportTitleDefinition.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/ReportTitleDefinition.cs
index c79c983a..f30d769e 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/ReportTitleDefinition.cs
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/ReportTitleDefinition.cs
@@ -1,15 +1,19 @@
-using System.Drawing;
+using System.Drawing;
namespace FastReport.ReportBuilder
{
- public class ReportTitleDefinition
+ ///
+ /// Stores presentation settings for the report title band.
+ ///
+ public class ReportTitleDefinition : TextBandDefinition
{
- public string Text { get; set; }
- public Font Font { get; set; } = new Font("Times New Roman", 14, FontStyle.Bold | FontStyle.Regular);
- public bool Visible { get; set; }
- public Color TextColor { get; set; } = Color.Black;
- public Color FillColor { get; set; }
- public VertAlign? VertAlign { get; set; }
- public HorzAlign? HorzAlign { get; set; }
+ ///
+ /// Initializes a new report title definition with title-specific defaults.
+ ///
+ public ReportTitleDefinition()
+ {
+ Font = new Font("Times New Roman", 14, FontStyle.Bold | FontStyle.Regular);
+ Height = 1.0f;
+ }
}
}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/TextBandDefinition.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/TextBandDefinition.cs
new file mode 100644
index 00000000..ca5ec1af
--- /dev/null
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/Definitions/TextBandDefinition.cs
@@ -0,0 +1,50 @@
+using System.Drawing;
+
+namespace FastReport.ReportBuilder
+{
+ ///
+ /// Stores presentation settings for a text-based report band.
+ ///
+ public class TextBandDefinition
+ {
+ ///
+ /// Gets or sets the text or expression rendered by the band.
+ ///
+ public string Text { get; set; }
+
+ ///
+ /// Gets or sets the font used by the band text.
+ ///
+ public Font Font { get; set; } = new Font("Times New Roman", 10.0f, FontStyle.Regular);
+
+ ///
+ /// Gets or sets a value indicating whether the band is rendered.
+ ///
+ public bool Visible { get; set; }
+
+ ///
+ /// Gets or sets the text color.
+ ///
+ public Color TextColor { get; set; } = Color.Black;
+
+ ///
+ /// Gets or sets the fill color.
+ ///
+ public Color FillColor { get; set; }
+
+ ///
+ /// Gets or sets the vertical text alignment.
+ ///
+ public VertAlign? VertAlign { get; set; }
+
+ ///
+ /// Gets or sets the horizontal text alignment.
+ ///
+ public HorzAlign? HorzAlign { get; set; }
+
+ ///
+ /// Gets or sets the band height in centimeters.
+ ///
+ public float Height { get; set; } = 0.5f;
+ }
+}
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/FastReport.ReportBuilder.csproj b/Extras/ReportBuilder/FastReport.ReportBuilder/FastReport.ReportBuilder.csproj
index 9e8a47e2..e7a4d94b 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder/FastReport.ReportBuilder.csproj
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/FastReport.ReportBuilder.csproj
@@ -1,7 +1,7 @@
- netstandard2.0
+ net462;net6.0
true
Fast Reports Inc.
Emrah KONDUR
@@ -26,8 +26,8 @@
-
-
+
+
diff --git a/Extras/ReportBuilder/FastReport.ReportBuilder/ReportHelper.cs b/Extras/ReportBuilder/FastReport.ReportBuilder/ReportHelper.cs
index 7d5065ba..13a0ab75 100644
--- a/Extras/ReportBuilder/FastReport.ReportBuilder/ReportHelper.cs
+++ b/Extras/ReportBuilder/FastReport.ReportBuilder/ReportHelper.cs
@@ -7,7 +7,7 @@
namespace FastReport.ReportBuilder
{
///
- /// Get instance for report builder
+ /// Creates fluent report builders.
///
public class ReportBuilder
{
@@ -15,8 +15,8 @@ public class ReportBuilder
/// Build a report
///
///
- ///
- ///
+ /// The records that will be registered as the report data source.
+ /// A typed report builder for the supplied data.
public ReportBuilder Report(IEnumerable data) where T : class
{
return new ReportBuilder(data);
@@ -24,16 +24,56 @@ public ReportBuilder Report(IEnumerable data) where T : class
}
///
- ///
+ /// Provides extension methods that materialize configured report builders into FastReport reports.
///
public static class ReportBuilderExtension
{
+ private static void ConfigurePage(ReportPage page, ReportDefinition definition)
+ {
+ page.Landscape = definition.Landscape;
+ page.LeftMargin = definition.LeftMargin;
+ page.TopMargin = definition.TopMargin;
+ page.RightMargin = definition.RightMargin;
+ page.BottomMargin = definition.BottomMargin;
+
+ if (definition.PaperWidth.HasValue)
+ {
+ page.PaperWidth = definition.PaperWidth.Value;
+ }
+
+ if (definition.PaperHeight.HasValue)
+ {
+ page.PaperHeight = definition.PaperHeight.Value;
+ }
+ }
+
+ private static void ConfigureTextBand(BandBase band, TextBandDefinition definition, ReportDefinition reportDefinition, ReportPage page)
+ {
+ band.CreateUniqueName();
+ band.Height = Units.Centimeters * definition.Height;
+ band.Visible = definition.Visible;
+
+ float bandWidth = (page.PaperWidth - page.LeftMargin - page.RightMargin) / 10 * Units.Centimeters;
+
+ var textObject = new TextObject();
+ textObject.Parent = band;
+ textObject.CreateUniqueName();
+ textObject.Bounds = new RectangleF(0, 0, bandWidth, band.Height);
+ textObject.Font = definition.Font;
+ textObject.Text = definition.Text;
+ textObject.TextColor = definition.TextColor;
+ textObject.FillColor = definition.FillColor;
+ textObject.VertAlign = definition.VertAlign ?? reportDefinition.VertAlign;
+ textObject.HorzAlign = definition.HorzAlign ?? reportDefinition.HorzAlign;
+ textObject.Border.Lines = BorderLines.All;
+ }
+
///
/// Prepare report when finished
///
///
- ///
- ///
+ /// The configured report builder instance.
+ /// A prepared ready for previewing or exporting.
public static Report Prepare(this ReportBuilder reportBuilder)
{
var report = new Report();
@@ -44,21 +84,46 @@ public static Report Prepare(this ReportBuilder reportBuilder)
ReportPage page = new ReportPage();
report.Pages.Add(page);
page.CreateUniqueName();
+ ConfigurePage(page, reportBuilder._report);
page.ReportTitle = new ReportTitleBand();
- page.ReportTitle.Height = Units.Centimeters * 1;
+ page.ReportTitle.Height = Units.Centimeters * reportBuilder._reportTitle.Height;
page.ReportTitle.CreateUniqueName();
page.ReportTitle.Visible = reportBuilder._reportTitle.Visible;
+ float titleBandWidth = (page.PaperWidth - page.LeftMargin - page.RightMargin) / 10 * Units.Centimeters;
+
TextObject titleText = new TextObject();
titleText.Parent = page.ReportTitle;
titleText.CreateUniqueName();
- titleText.Bounds = new RectangleF(Units.Centimeters * 5, 0, Units.Centimeters * 10, Units.Centimeters * 1);
+ titleText.Bounds = new RectangleF(0, 0, titleBandWidth, page.ReportTitle.Height);
titleText.Font = reportBuilder._reportTitle.Font;
titleText.Text = reportBuilder._reportTitle.Text;
titleText.TextColor = reportBuilder._reportTitle.TextColor;
titleText.FillColor = reportBuilder._reportTitle.FillColor;
- titleText.HorzAlign = HorzAlign.Center;
+ titleText.VertAlign = reportBuilder._reportTitle.VertAlign ?? reportBuilder._report.VertAlign;
+ titleText.HorzAlign = reportBuilder._reportTitle.HorzAlign ?? reportBuilder._report.HorzAlign;
+
+ if (reportBuilder._pageHeader.Visible)
+ {
+ page.PageHeader = new PageHeaderBand();
+ page.PageHeader.Parent = page;
+ ConfigureTextBand(page.PageHeader, reportBuilder._pageHeader, reportBuilder._report, page);
+ }
+
+ if (reportBuilder._pageFooter.Visible)
+ {
+ page.PageFooter = new PageFooterBand();
+ page.PageFooter.Parent = page;
+ ConfigureTextBand(page.PageFooter, reportBuilder._pageFooter, reportBuilder._report, page);
+ }
+
+ if (reportBuilder._reportSummary.Visible)
+ {
+ page.ReportSummary = new ReportSummaryBand();
+ page.ReportSummary.Parent = page;
+ ConfigureTextBand(page.ReportSummary, reportBuilder._reportSummary, reportBuilder._report, page);
+ }
DataBand dataBand = new DataBand();
dataBand.Parent = page;
@@ -113,8 +178,8 @@ public static Report Prepare(this ReportBuilder reportBuilder)
TextObject headerText = new TextObject();
headerText.CreateUniqueName();
headerText.Bounds = new RectangleF(leftCm, 0f * Units.Centimeters, cellWidth * Units.Centimeters * size, 0.1f * Units.Centimeters);
- headerText.VertAlign = reportBuilder._reportTitle.VertAlign ?? reportBuilder._report.VertAlign;
- headerText.HorzAlign = reportBuilder._reportTitle.HorzAlign ?? reportBuilder._report.HorzAlign;
+ headerText.VertAlign = reportBuilder._report.VertAlign;
+ headerText.HorzAlign = reportBuilder._report.HorzAlign;
headerText.Font = reportBuilder._dataHeader.Font;
headerText.TextColor = reportBuilder._dataHeader.TextColor;
headerText.FillColor = reportBuilder._dataHeader.FillColor;
diff --git a/Extras/ReportBuilder/README.md b/Extras/ReportBuilder/README.md
index 8bebec46..7a46fef0 100644
--- a/Extras/ReportBuilder/README.md
+++ b/Extras/ReportBuilder/README.md
@@ -5,10 +5,17 @@ Author: [Emrah KONDUR](https://github.com/ekondur)
var builder = new ReportBuilder();
var report = builder.Report(list)
+.Landscape()
+.PaperSize(210, 297)
+.Margins(15, 20, 15, 20)
.ReportTitle(title => title
.Text("Person Report - [MonthName(Month([Date]))]")
.HorzAlign(HorzAlign.Center)
)
+.PageHeader(header => header
+ .Text("Employee Directory")
+ .HorzAlign(HorzAlign.Center)
+)
.GroupHeader(header => header
.Condition(con => con.LastName)
.SortOrder(SortOrder.Descending)
@@ -26,6 +33,13 @@ var report = builder.Report(list)
data.Column(col => col.IsActive).Title("Active").Width(10);
data.Column(col => col.Level).HorzAlign(HorzAlign.Center);
})
+.PageFooter(footer => footer
+ .Text("Page [Page#] of [TotalPages#]")
+ .HorzAlign(HorzAlign.Right)
+)
+.ReportSummary(summary => summary
+ .Text("Report completed")
+)
.Prepare();
```
@@ -34,4 +48,4 @@ Install [FastReport.ReportBuilder](https://www.nuget.org/packages/FastReport.Rep
```
PM> Install-Package FastReport.ReportBuilder
-```
\ No newline at end of file
+```