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"));
        }
        public void Test1()
        {
            var dc = new DataContext();

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

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

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

            var          rep = Report.CreateReport(flow, dc);
            StringWriter sw  = new StringWriter();

            TextReportWriter.WriteTo(rep, sw);

            var lines = sw.ToString().Split('\n').Select(a => a.TrimEnd('\r')).ToArray();

            Assert.AreEqual(lines[1], "=========");
            Assert.AreEqual(lines[2], "Col1 Col2");
            Assert.AreEqual(lines[3], "---- ----");
            Assert.AreEqual(lines[4], "A       2");
            Assert.AreEqual(lines[5], "---------");
        }
        public void Test2()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Name="1", Value = 2, G="1" },
                new Item { Name="2", Value = 3, G="1" },
                new Item { Name="3", Value = 4, G="2" }
            });

            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(1, cells[2][0].Value);

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

            //Accumulator
            Assert.AreEqual(2, cells[0][2].Value);
            Assert.AreEqual(5, cells[1][2].Value);
            //G2
            Assert.AreEqual(4, cells[2][2].Value);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
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"));
        }
    }
        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);
        }
Beispiel #9
0
        public static Report Generate()
        {
            var dc = new DataContext();
            var data = from item in Pecunia.Services.GdpDataProvider.GetData()
                       select new Item
                       {
                           Country = item.Country,
                           GDP = item.GDP,
                           GdpGrowth = item.GDPGrowth,
                           Year = item.Year,
                           GniPerCapita = item.GniPerCapita
                       };
            dc.AddTable("data", data.ToArray());

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            var table = flow.AddTable<Item>("data");
            table.Columns.Single(a => a.DataField == "GdpGrowth").ConditionalFormatting = ConditionalFormatters.PercentChange;

            return Report.CreateReport(flow, dc);
        }
Beispiel #10
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 };
            flow.AddTable<Item>("data");

            var rep = Report.CreateReport(flow, dc);
            StringWriter sw = new StringWriter();
            TextReportWriter.WriteTo(rep, sw);

            var lines = sw.ToString().Split('\n').Select(a=>a.TrimEnd('\r')).ToArray();

            Assert.AreEqual(lines[1], "=========");
            Assert.AreEqual(lines[2], "Col1 Col2");
            Assert.AreEqual(lines[3], "---- ----");
            Assert.AreEqual(lines[4], "A       2");
            Assert.AreEqual(lines[5], "---------");
        }
Beispiel #11
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);
        }
        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);
        }
Beispiel #13
0
        public static Report Generate()
        {
            var dc   = new DataContext();
            var data = from item in Pecunia.Services.GdpDataProvider.GetData()
                       select new Item
            {
                Country      = item.Country,
                GDP          = item.GDP,
                GdpGrowth    = item.GDPGrowth,
                Year         = item.Year,
                GniPerCapita = item.GniPerCapita
            };

            dc.AddTable("data", data.ToArray());

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

            table.Columns.Single(a => a.DataField == "GdpGrowth").ConditionalFormatting = ConditionalFormatters.PercentChange;

            return(Report.CreateReport(flow, dc));
        }
Beispiel #14
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);
        }
        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);
        }
Beispiel #16
0
 public Report GenerateReport()
 {
     var flow = new Flow { Orientation = FlowOrientation.Vertical };
     flow.AddTable<Item>("table");
     return Report.CreateReport(flow, GetData());
 }
Beispiel #17
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);
        }