Example #1
0
        public void Test1()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item {
                    Name = "1", Value = 2
                },
                new Item {
                    Name = "2", Value = 3
                },
                new Item {
                    Name = "3", Value = 4
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.AddTable <Item>("data");

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //RowNumber
            Assert.AreEqual(1, cells[0][0].Value);
            Assert.AreEqual(2, cells[1][0].Value);
            Assert.AreEqual(3, cells[2][0].Value);

            //RowNumber
            Assert.AreEqual(2, cells[0][2].Value);
            Assert.AreEqual(5, cells[1][2].Value);
            Assert.AreEqual(9, cells[2][2].Value);
        }
Example #2
0
        public void TestFooters()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item2 {
                    Name = "1", Value = 2, G = "1", Weight = 3
                },
                new Item2 {
                    Name = "2", Value = 3, G = "1", Weight = 1
                },
                new Item2 {
                    Name = "3", Value = 4, G = "2", Weight = 4
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.AddTable <Item2>("data");

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Debug.WriteLine(ReportUtil.RenderTextReport(rep));

            Assert.AreEqual(6, cells.Count);

            //Footers
            Assert.AreEqual(9m / 4, cells[2][2].Value);
            Assert.AreEqual(16m / 4, cells[4][2].Value);
            Assert.AreEqual(25m / 8, cells[5][2].Value);
        }
Example #3
0
        public void TestFooters()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item2 {
                    Name = "1", Value = 2, G = "1"
                },
                new Item2 {
                    Name = "2", Value = 3, G = "1"
                },
                new Item2 {
                    Name = "3", Value = 4, G = "2"
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.AddTable <Item2>("data");

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //Debug.WriteLine(ReportUtil.RenderTextReport(rep));

            Assert.AreEqual(6, cells.Count);

            //RowNumber
            Assert.AreEqual(1, cells[0][0].Value);
            Assert.AreEqual(2, cells[1][0].Value);
            Assert.AreEqual(1, cells[3][0].Value);

            //G2
            Assert.AreEqual(1, cells[3][0].Value);

            //Accumulator
            Assert.AreEqual(2, cells[0][2].Value);
            Assert.AreEqual(5, cells[1][2].Value);
            //G2
            Assert.AreEqual(4, cells[3][2].Value);

            //Footers
            Assert.AreEqual(5, cells[2][2].Value);
            Assert.AreEqual(4, cells[4][2].Value);
            Assert.AreEqual(9, cells[5][2].Value);
        }
Example #4
0
        public void Test2()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item {
                    Col1 = "A", Col2 = 2
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };
            var table = flow.AddTable <Item>("data");

            table.Columns.Single(a => a.DataField == "Col2").ConditionalFormatting = (value) => {
                if (!(value is int))
                {
                    return(null);
                }
                var v = (int)value;
                if (v > 0)
                {
                    return new Styling.CellStyle
                           {
                               FontStyle = new Styling.FontStyle
                               {
                                   FontColor = Styling.Color.FromHtml("#00FF00")
                               }
                           }
                }
                ;
                return(null);
            };

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Assert.IsNull(cells[0][0].CustomStyle);
            Assert.IsNotNull(cells[0][1].CustomStyle);

            var html = HtmlReportWriter.RenderReport(rep, new DefaultHtmlReportTheme());

            Assert.IsTrue(html.Contains("style=\"color:"));
            Assert.IsTrue(html.Contains("#00FF00"));
        }
    }
Example #5
0
        public void Test1()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item {
                    Col1 = "A", Col2 = 2
                }
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };
            var table = flow.AddTable <Item>("data");

            table.Columns.Single(a => a.DataField == "Col2").ConditionalFormatting = (value) => { return(new Styling.CellStyle()); };

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Assert.IsNull(cells[0][0].CustomStyle);
            Assert.IsNotNull(cells[0][1].CustomStyle);
        }
Example #6
0
        public void TwoLevelGrouping()
        {
            var dc = new DataContext();

            dc.AddTable("data", new[] {
                new Item {
                    Amount = 10, BrokerageHouseCode = "ADBR", Revoked = false
                },
                new Item {
                    Amount = 20, BrokerageHouseCode = "ADBR", Revoked = true
                },
                new Item {
                    Amount = 30, BrokerageHouseCode = "MOBR", Revoked = true
                },
            });

            var flow = new Flow {
                Orientation = FlowOrientation.Vertical
            };

            flow.AddTable <Item>("data");

            var rep   = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

//False
//=================================
//ADBR
//=================================
//BrokerageHouseCode Revoked Amount
//------------------ ------- ------
//ADBR               False       10
//---------------------------------
//                               10
//---------------------------------
//                               10

//True
//=================================
//ADBR
//=================================
//BrokerageHouseCode Revoked Amount
//------------------ ------- ------
//ADBR               True        20
//---------------------------------
//                               20

//MOBR
//=================================
//BrokerageHouseCode Revoked Amount
//------------------ ------- ------
//MOBR               True        30
//---------------------------------
//                               30
//---------------------------------
//                               50

            //Debug.WriteLine(ReportUtil.RenderTextReport(rep));
            Assert.AreEqual(16, cells.Count);

            Assert.AreEqual("False", cells[0][0].Value);
            Assert.AreEqual("ADBR", cells[1][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[2][0].Value);
            Assert.AreEqual(10m, cells[3][2].Value);
            Assert.AreEqual(10m, cells[4][2].Value);
            Assert.AreEqual(10m, cells[5][2].Value);
            Assert.AreEqual("True", cells[6][0].Value);
            Assert.AreEqual("ADBR", cells[7][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[8][0].Value);
            Assert.AreEqual(20m, cells[9][2].Value);
            Assert.AreEqual(20m, cells[10][2].Value);
            Assert.AreEqual("MOBR", cells[11][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[12][0].Value);
            Assert.AreEqual(30m, cells[13][2].Value);
            Assert.AreEqual(30m, cells[14][2].Value);
            Assert.AreEqual(50m, cells[15][2].Value);
        }