Devexpress 明细报表
public class InOrder { public String Title { get; set; } public String EmpNo { get; set; } public List<InOrderItem> Items { get; set; } public decimal? GroupSum { get { return Items.Sum(ent => ent.Amount); } } public InOrder() { Items = new List<InOrderItem>(); } } public class InOrderItem { public long? Id { get; set; } public decimal? Amount { get; set; } public String Name { get; set; } }
public List<InOrder> Orders = new List<InOrder>(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { var rnd = new Random(Environment.TickCount); for (int i = 0; i < 10; i++) { var order = new InOrder(); order.EmpNo = "00102" + i; order.Title = "入库单" + Guid.NewGuid().ToString(); Orders.Add(order); var itemCount = rnd.Next(10, 60); for (int j = 0; j < itemCount; j++) { var item = new InOrderItem(); order.Items.Add(item); item.Id = j; item.Name = "项目" + Path.GetRandomFileName(); item.Amount =(decimal) rnd.NextDouble() * 100; } } } private void button1_Click(object sender, EventArgs e) { #region var rpt = new XtraReport1(); rpt.DataSource = Orders; rpt.RequestParameters = false; rpt.PrintingSystem.ShowMarginsWarning = false; rpt.PrintingSystem.ShowPrintStatusDialog = false; ReportPrintTool printTool = new ReportPrintTool(rpt); printTool.Report.CreateDocument(false); printTool.PrintingSystem.ShowMarginsWarning = false; Application.DoEvents(); printTool.ShowPreviewDialog(); #endregion }
先设置下报表尺寸为A4
A4= 210mm × 297 mm
Letter= 216mm × 279mm (8.5X11英寸)度
letter size是纸张尺寸的一种,主要应用与美国、墨西哥和加拿大等国家。