Esempio n. 1
0
        public void CellsAreInitWhenRowIsCreated()
        {
            var row = new ExcelReportRow();

            Assert.IsNotNull(row.Cells);
            Assert.AreEqual(0, row.Cells.Count);
        }
Esempio n. 2
0
        public void HasDataReturnFalseWhenNoneOfTheCellsOfTheGridHasAnyValue()
        {
            var row = new ExcelReportRow();

            row.Cells.Add(new ExcelReportCell());
            Assert.IsFalse(row.HasData);
        }
Esempio n. 3
0
        public void HasDataReturnFalseWhenOnlyFirstCellHasValue()
        {
            var row = new ExcelReportRow();

            row.Cells.Add(new ExcelReportCell()
            {
                Value = 10
            });
            Assert.IsFalse(row.HasData);
        }
Esempio n. 4
0
        private ExcelReportGrid ScenarioDetailsGrid(RunModel run, ScenarioModel scenario, int maxColumnsCount, DateTime reportDate)
        {
            var grid = new ExcelReportGrid();

            grid.MaxColumnCount = maxColumnsCount;
            var row1 = new ExcelReportRow();

            row1.Cells.Add(new ExcelReportCell()
            {
                Value = "Report Date", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.HeaderStyle.Name
            });
            row1.Cells.Add(new ExcelReportCell()
            {
                Value = string.Format(CultureInfo.InvariantCulture, "{0:dd MMMM yyyy} - {0:HH:mm:ss}", reportDate), Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.HeaderStyle.Name
            });
            grid.HeaderRows.Add(row1);

            var row2 = new ExcelReportRow();

            row2.Cells.Add(new ExcelReportCell()
            {
                Value = "Run Name", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
            });
            row2.Cells.Add(new ExcelReportCell()
            {
                Value = run.Description, Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
            });
            grid.BodyRows.Add(row2);

            var row3 = new ExcelReportRow();

            row3.Cells.Add(new ExcelReportCell()
            {
                Value = "Run Id", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
            });
            row3.Cells.Add(new ExcelReportCell()
            {
                Value = run.Id, Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
            });
            grid.BodyRows.Add(row3);

            var row4 = new ExcelReportRow();

            row4.Cells.Add(new ExcelReportCell()
            {
                Value = "Scenario Name", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
            });
            row4.Cells.Add(new ExcelReportCell()
            {
                Value = scenario.Name, Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
            });
            grid.BodyRows.Add(row4);

            return(grid);
        }
Esempio n. 5
0
        public void HasDataReturnTrueWhenAtleastOneOfTheCellsNotInTheFirstColumnHasValue()
        {
            var row = new ExcelReportRow();

            row.Cells.Add(new ExcelReportCell());
            row.Cells.Add(new ExcelReportCell()
            {
                Value = 10
            });
            Assert.IsTrue(row.HasData);
        }
Esempio n. 6
0
        public void HasDataReturnFalseWhenNoneOfTheCellsOfTheGridHasAnyValue()
        {
            var grid = new ExcelReportGrid();
            var row1 = new ExcelReportRow();
            var row2 = new ExcelReportRow();

            row1.Cells.Add(new ExcelReportCell());
            row2.Cells.Add(new ExcelReportCell());
            grid.BodyRows.Add(row1);
            grid.BodyRows.Add(row2);
            Assert.IsFalse(grid.HasData);
        }
Esempio n. 7
0
        public void HasDataReturnFalseWhenOnlyFirstColumnHasValue()
        {
            var grid = new ExcelReportGrid();
            var row1 = new ExcelReportRow();
            var row2 = new ExcelReportRow();

            row1.Cells.Add(new ExcelReportCell()
            {
                Value = 10
            });
            row2.Cells.Add(new ExcelReportCell());
            grid.BodyRows.Add(row1);
            grid.BodyRows.Add(row2);
            Assert.IsFalse(grid.HasData);
        }
Esempio n. 8
0
 private void WriteRow(ISheetBuilder sb, ExcelReportGrid grid, ExcelReportRow row)
 {
     sb.Block(bb =>
     {
         for (var i = 0; i < row.Cells.Count; i++)
         {
             var cell    = row.Cells[i];
             var colSpan = 1;
             if (i > 0)
             {
                 colSpan = (grid.MaxColumnCount - 1) / (row.Cells.Count - 1);
             }
             writeCell(bb, cell, colSpan);
         }
     });
 }
Esempio n. 9
0
        public void HasDataReturnTrueWhenAtleastOneOfTheCellsNotInTheFirstColumnHasValue()
        {
            var grid = new ExcelReportGrid();
            var row1 = new ExcelReportRow();
            var row2 = new ExcelReportRow();

            row1.Cells.Add(new ExcelReportCell());
            row1.Cells.Add(new ExcelReportCell()
            {
                Value = 10
            });
            row2.Cells.Add(new ExcelReportCell());
            grid.BodyRows.Add(row1);
            grid.BodyRows.Add(row2);
            Assert.IsTrue(grid.HasData);
        }
Esempio n. 10
0
        private List <ExcelReportRow> GetBodyRows(Dictionary <string, object[]> data, string firstColumnStyleName = null)
        {
            var rows             = new List <ExcelReportRow>();
            var alternativeColor = true;

            foreach (var item in data)
            {
                alternativeColor = !alternativeColor;
                var row = new ExcelReportRow();
                row.Cells.Add(new ExcelReportCell()
                {
                    Value = ValueOf(item.Key), Alignment = ExcelHorizontalAlignment.Left, StyleName = string.IsNullOrEmpty(firstColumnStyleName) ? GamePlanReportStyles.DataCellStyle.Name : firstColumnStyleName, AlternateBackground = alternativeColor
                });
                foreach (var v in item.Value)
                {
                    row.Cells.Add(new ExcelReportCell()
                    {
                        Value = ValueOf(v), Alignment = ExcelHorizontalAlignment.Center, StyleName = GamePlanReportStyles.DataCellStyle.Name, AlternateBackground = alternativeColor
                    });
                }
                rows.Add(row);
            }
            return(rows);
        }
Esempio n. 11
0
        private List <ExcelReportRow> GetGenericHeaderRowsForRunReport(List <PassModel> passes, string title, string subTitleFirstColumn = null, string[] subtitleRepeatColumns = null)
        {
            var row1 = new ExcelReportRow();

            row1.Cells.Add(new ExcelReportCell()
            {
                Value = title, Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.HeaderStyle.Name
            });
            row1.Cells.Add(new ExcelReportCell()
            {
                Value = "Value", Alignment = ExcelHorizontalAlignment.Center, StyleName = GamePlanReportStyles.HeaderStyle.Name
            });

            var row2 = new ExcelReportRow();
            var row3 = new ExcelReportRow();
            var row4 = new ExcelReportRow();

            row2.Cells.Add(new ExcelReportCell()
            {
                Value = "Pass#", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
            });
            row3.Cells.Add(new ExcelReportCell()
            {
                Value = "Pass Name", Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
            });
            if (!string.IsNullOrEmpty(subTitleFirstColumn))
            {
                row4.Cells.Add(new ExcelReportCell()
                {
                    Value = subTitleFirstColumn, Alignment = ExcelHorizontalAlignment.Left, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
                });
            }
            for (var i = 0; i < passes.Count; i++)
            {
                row2.Cells.Add(new ExcelReportCell()
                {
                    Value = i + 1, Alignment = ExcelHorizontalAlignment.Center, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
                });
                row3.Cells.Add(new ExcelReportCell()
                {
                    Value = passes[i].Name, Alignment = ExcelHorizontalAlignment.Center, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
                });
                if (subtitleRepeatColumns != null)
                {
                    foreach (var subtitle in subtitleRepeatColumns)
                    {
                        row4.Cells.Add(new ExcelReportCell()
                        {
                            Value = subtitle, Alignment = ExcelHorizontalAlignment.Center, StyleName = GamePlanReportStyles.LightHeaderStyle.Name
                        });
                    }
                }
            }
            var rows = new List <ExcelReportRow>()
            {
                row1, row2, row3
            };

            if (row4.HasData)
            {
                rows.Add(row4);
            }
            return(rows);
        }
Esempio n. 12
0
 private string GetRowValue(ExcelReportRow r)
 {
     return(String.Join(",", r.Cells.Select(c => c.Value != null ? c.Value.ToString() : "").ToArray()));
 }