Integrate DevExpress Reporting for envelope history

Added DevExpress.Reporting.Core package reference. Refactored rptEnvelopeHistory to inherit from XtraReport and build its layout programmatically using DevExpress bands, tables, and styling. The report now uses A4 paper size, custom margins, and DevExpress UI components for rendering.
This commit is contained in:
2026-03-09 21:27:06 +01:00
parent b65367fb6d
commit 7af934ea19
2 changed files with 87 additions and 1 deletions

View File

@@ -17,6 +17,7 @@
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.16" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="DevExpress.Reporting.Core" Version="24.2.*" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,9 +1,94 @@
using DevExpress.XtraReports.UI;
using DevExpress.Drawing;
using System.Drawing;
using System.IO;
namespace EnvelopeGenerator.ServiceHost.Jobs.FinalizeDocument;
public class rptEnvelopeHistory
public class rptEnvelopeHistory : XtraReport
{
public rptEnvelopeHistory()
{
BuildLayout();
}
private void BuildLayout()
{
Bands.AddRange(
[
new TopMarginBand(),
new BottomMarginBand(),
new ReportHeaderBand { HeightF = 40 },
new PageHeaderBand { HeightF = 24 },
new DetailBand { HeightF = 22 }
]);
var reportHeader = (ReportHeaderBand)Bands[nameof(ReportHeaderBand)]!;
var pageHeader = (PageHeaderBand)Bands[nameof(PageHeaderBand)]!;
var detail = (DetailBand)Bands[nameof(DetailBand)]!;
var title = new XRLabel
{
BoundsF = new RectangleF(0, 0, 750, 28),
Font = new DXFont("Segoe UI", 14, DXFontStyle.Bold),
Text = "Envelope History"
};
reportHeader.Controls.Add(title);
var headerTable = CreateTable(isHeader: true);
pageHeader.Controls.Add(headerTable);
var detailTable = CreateTable(isHeader: false);
detail.Controls.Add(detailTable);
Margins = new DXMargins(40, 40, 40, 40);
PaperKind = (DevExpress.Drawing.Printing.DXPaperKind)System.Drawing.Printing.PaperKind.A4;
}
private static XRTable CreateTable(bool isHeader)
{
var table = new XRTable
{
BoundsF = new RectangleF(0, 0, 750, 22),
Borders = DevExpress.XtraPrinting.BorderSide.All
};
var row = new XRTableRow();
if (isHeader)
{
row.Font = new DXFont("Segoe UI", 9, DXFontStyle.Bold);
row.BackColor = Color.Gainsboro;
row.Cells.Add(CreateCell("Date"));
row.Cells.Add(CreateCell("Status"));
row.Cells.Add(CreateCell("User"));
row.Cells.Add(CreateCell("Title"));
row.Cells.Add(CreateCell("Subject"));
}
else
{
row.Font = new DXFont("Segoe UI", 9, DXFontStyle.Regular);
row.Cells.Add(CreateCell("[ItemDate]"));
row.Cells.Add(CreateCell("[ItemStatusTranslated]"));
row.Cells.Add(CreateCell("[ItemUserReference]"));
row.Cells.Add(CreateCell("[EnvelopeTitle]"));
row.Cells.Add(CreateCell("[EnvelopeSubject]"));
}
table.Rows.Add(row);
return table;
}
private static XRTableCell CreateCell(string textOrExpression)
{
return new XRTableCell
{
Text = textOrExpression,
Padding = new DevExpress.XtraPrinting.PaddingInfo(4, 4, 2, 2),
CanGrow = false
};
}
public object? DataSource { get; set; }
public string? DataMember { get; set; }