Ejemplo n.º 1
0
        public static DataItemReport CombineHorizontally(DataItemReport report1, DataItemReport report2)
        {
            var combo = new DataItemReport();

            if (report1.IsEmpty())
            {
                combo = report2.Copy();
            }

            else if (report2.IsEmpty())
            {
                combo = report1.Copy();
            }

            else
            {
                // report has columns but no rows. add a row with empty items.
                if (report1.Rows.Count == 0)
                {
                    var dummy = report1.Copy();
                    dummy.AddEmptyRow();
                    report1 = dummy;
                }

                if (report2.Rows.Count == 0)
                {
                    var dummy = report2.Copy();
                    dummy.AddEmptyRow();
                    report2 = dummy;
                }

                // combine the colummns.
                combo.AddColumns(report1);
                combo.AddColumns(report2);

                // combine rows.
                foreach (var row1 in report1.Rows)
                {
                    foreach (var row2 in report2.Rows)
                    {
                        var comboRow = new DataItemList();
                        comboRow.AddRange(row1);
                        comboRow.AddRange(row2);

                        combo.Rows.Add(comboRow);
                    }
                }
            }

            return(combo);
        }
Ejemplo n.º 2
0
        public static DataItemReport CombineVertically(DataItemReport report1, DataItemReport report2)
        {
            var combo = new DataItemReport();

            // set the columns of the combined reports to the columns of either report1
            // or report 2.
            combo.AddColumns(report1);
            if (combo.Columns.Count == 0)
            {
                combo.AddColumns(report2);
            }

            // combine the report columns of the two input reports.
            combo.AddRows(report1);
            combo.AddRows(report2);

            return(combo);
        }