示例#1
0
        void BasicCustomerList()
        {
            report            = new Report();
            report.DataSource = customers.OrderBy(c => c.CompanyName);
            //report.SelectedOrientation = Report.Orientations.Landscape;
            //report.SelectedPageType = Report.PageSizes.A5;

            report.AddField("Id", 50, HeaderLabel: "ID");
            report.AddField("CompanyName", 150, HeaderLabel: "Name");
            report.AddField("Address", 200, HeaderLabel: "Address");
            report.AddField("City", 200, HeaderLabel: "City");

            report.ReportHeader = new ReportSection()
            {
                Height        = 100,
                ReportObjects =
                {
                    new ReportObjectLabel("Report header", 0, 1, Width:150)
                },
                ForceNewPage = ReportSection.ForceNewPageTypes.AfterSection
            };
            report.ReportFooter = new ReportSection()
            {
                Height        = 100,
                ReportObjects =
                {
                    new ReportObjectLabel("Report footer", 0, 1, Width:150)
                },
                ForceNewPage = ReportSection.ForceNewPageTypes.BeforeSection
            };
        }
示例#2
0
        public void OrderWithSubReport()
        {
            var selectedOrders = orders.Take(100);

            selectedOrders.ToList().ForEach(o => o.OrderDetails = orderDetails.Where(od => od.OrderID == o.OrderID).ToList());

            Report orderDetail = new Report();

            orderDetail.AddField("ProductID", 20, HeaderLabel: "ID");
            orderDetail.AddField("Product.ProductName", 150, HeaderLabel: "Description");
            orderDetail.AddField("UnitPrice", 75, Mask: "0.00", HeaderLabel: "Unit price", Alignment: Alignment.Right);
            orderDetail.AddField("Quantity", 75, HeaderLabel: "Quantity", Mask: "0", Alignment: Alignment.Right);
            orderDetail.AddField("Discount", 75, HeaderLabel: "Discount", Mask: "0.00", Alignment: Alignment.Right);
            orderDetail.AddField("NetAmount", 75, HeaderLabel: "Net amount", Mask: "0.00", Alignment: Alignment.Right);
            //orderDetail.PageHeader.Height = 0;
            //orderDetail.PageFooter.Height = 0;
            //orderDetail.PageHeader.ReportObjects.Add(new ReportObjectLine() { XRight = 100 });
            //orderDetail.AlternatingRowsPrimaryColor = Color.Yellow;
            //orderDetail.AlternatingRowsPrimaryColor = Color.Green;
            //orderDetail.DetailSection.Height = 15;
            //orderDetail.DetailSection.ReportObjects.Add(new ReportObjectLine() { XRight = 100, YTop=15, YBottom=15 });
            report            = NewReport("Order - subreport demo");
            report.DataSource = selectedOrders;
            report.AddField("OrderID", 100);
            report.DetailSection.ReportObjects.Add(new ReportObjectSubReport()
            {
                SubReport = orderDetail, DataSource = "OrderDetails", XLeft = 20, XRight = 500, YTop = 15, YBottom = 65
            });
        }
示例#3
0
        void CustomerListPerCountry()
        {
            report            = NewReport("Customer list by country");
            report.DataSource = customers.OrderBy(c => c.Country);

            report.AddField("Id", 50, X: 5, HeaderLabel: "ID");
            report.AddField("CompanyName", 100, HeaderLabel: "Name");
            report.AddField("Address", 100, HeaderLabel: "Address");
            report.AddField("City", 100, HeaderLabel: "City");

            report.ReportGroups.Add(new ReportGroup()
            {
                GroupingKey   = "Country",
                HeaderSection = new ReportSection()
                {
                    Height        = 18,
                    ReportObjects =
                    {
                        new ReportObjectRectangle()
                        {
                            XLeft = 0, XRight = report.PrintableAreaWidth, YTop = 0, YBottom = 14
                        },
                        new ReportObjectField("Country", 3, 0, Width:100)
                    }
                },
                FooterSection = new ReportSection()
                {
                    Height        = 25,
                    ReportObjects =
                    {
                        new ReportObjectLabel("Customer count:",  0, 1, Width:150),
                        new ReportObjectField("count(id)",       80, 1, Width:120)
                    }
                }
            });
        }
示例#4
0
        void ProductList()
        {
            report            = NewReport("ProductList");
            report.DataSource = products.OrderBy(p => p.ProductID);
            report.AddField("ProductID", 60, X: 15, HeaderLabel: "Product ID");
            report.AddField("ProductName", 150, HeaderLabel: "Description", CanGrow: true);
            report.AddField("UnitPrice", 60, HeaderLabel: "Unit price", Alignment: Alignment.Right, Mask: "0.00");
            report.AddField("UnitsInStock", 60, HeaderLabel: "Stock qty", Alignment: Alignment.Right);
            report.AddField("UnitsOnOrder", 60, HeaderLabel: "On order qty", Alignment: Alignment.Right, Mask: "#");
            report.AddField("ReorderLevel", 60, HeaderLabel: "Reorder lvl", Alignment: Alignment.Right, Mask: "#");

            report.DetailSection.ReportObjects.Add(new ReportObjectImage()
            {
                ImageFileName = @"C:\Users\Pascal\Pictures\discontinued.png", XLeft = 0, YTop = 0, YBottom = 11, ID = "discontinued"
            });

            report.DetailSection.IsVisible += DetailSection_IsVisible;
        }
示例#5
0
        public void OrderNotes()
        {
            report            = new Report();
            report.DataSource = orderDetails.Take(100);

            report.ReportGroups.Add(new ReportGroup()
            {
                GroupingKey    = "OrderID",
                StartOnNewPage = true,
                HeaderSection  = new ReportSection()
                {
                    ReportObjects =
                    {
                        new ReportObjectImage()
                        {
                            ImageFileName = @"C:\Users\Pascal\Pictures\Icebear reporting company logo.png", XLeft = 0, YTop = 0, YBottom = 25
                        },
                        new ReportObjectLabel("Icebear report company", 0, 28, Width:150, Alignment:Alignment.Center),
                        new ReportObjectLabel("52nd Street 54", 0, 40, Width:150, Alignment:Alignment.Center),
                        new ReportObjectLabel("New York", 0, 52, Width:150, Alignment:Alignment.Center),

                        new ReportObjectField("Order.ShipName", 300, 70, Width:250),
                        new ReportObjectField("Order.ShipAddress", 300, 80, Width:250),
                        new ReportObjectField("Order.ShipPostalCode", 300, 90, Width:50),
                        new ReportObjectField("Order.ShipCity", 350, 90, Width:200),
                        new ReportObjectField("Order.ShipCountry", 300, 100, Width:250),

                        new ReportObjectRectangle()
                        {
                            XLeft = 0, XRight = report.PrintableAreaWidth, YTop = 130, YBottom = 150
                        },
                    },
                    Height = 200
                },
                FooterSection = new ReportSection()
                {
                    ReportObjects = new List <IReportObject>()
                    {
                        new ReportObjectField("Order.Comment", 0, 0, Width: report.PrintableAreaWidth, Heigth: 1)
                        {
                            CanGrow = true
                        },
                        new ReportObjectRectangle()
                        {
                            XLeft = 0, XRight = report.PrintableAreaWidth, YTop = 1, YBottom = 80
                        },
                        new ReportObjectLabel("Total orderamount ex VAT", 300, 45, Width: 150),
                        new ReportObjectField("sum(NetAmount)", 450, 45, Width: 75, Mask: "0.00", Alignment: Alignment.Right),
                        new ReportObjectLabel("Vat", 300, 55, Width: 150),
                        new ReportObjectField()
                        {
                            FieldName = "sum(Vat)", XLeft = 450, XRight = 525, YTop = 55, YBottom = 65, Mask = "0.00", Alignment = Alignment.Right
                        },
                        new ReportObjectLabel("Total orderamount", 300, 65, Width: 150),
                        new ReportObjectField()
                        {
                            FieldName = "sum(TotalAmount)", XLeft = 450, XRight = 525, YTop = 65, YBottom = 75, Mask = "0.00", Alignment = Alignment.Right
                        }
                    },
                    Height = 100
                }
            });

            report.SectionForAutoHeaderLabels     = report.ReportGroups[0].HeaderSection; // we want the headerlabels of the detail fields in the groupheader not in the pageheader which is the default
            report.YTopForAutoAddedFieldsInHeader = 133;
            report.AddField("ProductID", 20, HeaderLabel: "ID");
            report.AddField("Product.ProductName", 150, HeaderLabel: "Description");
            report.AddField("UnitPrice", 75, Mask: "0.00", HeaderLabel: "Unit price", Alignment: Alignment.Right);
            report.AddField("Quantity", 75, HeaderLabel: "Quantity", Mask: "0", Alignment: Alignment.Right);
            report.AddField("Discount", 75, HeaderLabel: "Discount", Mask: "0.00", Alignment: Alignment.Right);
            report.AddField("NetAmount", 75, HeaderLabel: "Net amount", Mask: "0.00", Alignment: Alignment.Right);
        }