Beispiel #1
0
        /// <summary>
        /// The update items.
        /// </summary>
        public void UpdateItems()
        {
            this.Rows.Clear();
            this.Columns.Clear();
            if (this.Fields == null || this.Fields.Count == 0)
            {
                return;
            }

            string[,] cells = this.ToArray();

            int rows    = cells.GetUpperBound(0) + 1;
            int columns = cells.GetUpperBound(1) + 1;

            for (int i = 0; i < rows; i++)
            {
                var tr = new TableRow();
                if (this.ItemsInRows)
                {
                    tr.IsHeader = i == 0;
                }

                this.Rows.Add(tr);
                for (int j = 0; j < columns; j++)
                {
                    var tc = new TableCell();
                    tc.Content = cells[i, j];
                    tr.Cells.Add(tc);
                }
            }

            for (int j = 0; j < columns; j++)
            {
                var tc = new TableColumn();
                if (this.ItemsInRows)
                {
                    ItemsTableField f = this.Fields[j];
                    tc.Alignment = f.Alignment;
                    tc.Width     = f.Width;
                }
                else
                {
                    tc.IsHeader  = j == 0;
                    tc.Alignment = this.Alignment;
                }

                this.Columns.Add(tc);
            }
        }
Beispiel #2
0
        /// <summary>
        /// The to array.
        /// </summary>
        /// <returns>
        /// </returns>
        public string[,] ToArray()
        {
            List <object> items = this.Items.Cast <object>().ToList();
            int           nrows = items.Count;

            bool hasHeader = this.HasHeader();

            if (hasHeader)
            {
                nrows++;
            }

            var result = new string[nrows, this.Fields.Count];

            int row = 0;

            if (hasHeader)
            {
                for (int i = 0; i < this.Fields.Count; i++)
                {
                    ItemsTableField c = this.Fields[i];
                    result[row, i] = c.Header;
                }

                row++;
            }

            foreach (var item in items)
            {
                for (int i = 0; i < this.Fields.Count; i++)
                {
                    ItemsTableField c    = this.Fields[i];
                    string          text = c.GetText(item, this.Report.ActualCulture);
                    result[row, i] = text;
                }

                row++;
            }

            if (!this.ItemsInRows)
            {
                result = Transpose(result);
            }

            return(result);
        }