コード例 #1
0
        public ExportGrid Change()
        {
            this._getColumnList();

            ExportRow row = null;

            foreach (object obj in this._originalSource)
            {
                row = new ExportRow(this._grid.OriginalColumnList.Count);
                foreach (string col in this._cols)
                {
                    if (col.ToUpper() != this._rowCol.ToUpper() &&
                        col.ToUpper() != this._colRow.ToUpper())
                    {
                        object objValue = DomainObjectUtility.GetValue(obj, col, null);
                        if (objValue != null)
                        {
                            row.AddCellText(objValue.ToString());
                        }
                        else
                        {
                            row.AddCellText(ExportCell.CellEmpty);
                        }
                    }
                    else if (col.ToUpper() == this._colRow.ToUpper())
                    {
                        object objColRow = DomainObjectUtility.GetValue(obj, col, null);
                        if (objColRow != null)
                        {
                            object objRowCol = DomainObjectUtility.GetValue(obj, this._rowCol, null);
                            if (objRowCol != null)
                            {
                                for (int i = 0; i < this._grid.OriginalColumnList.Count; i++)
                                {
                                    if ((this._grid.OriginalColumnList[i] as ExportColumn).Key.ToUpper() ==
                                        objRowCol.ToString().ToUpper())
                                    {
                                        row.CellList[i] = objColRow;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(this._grid);
        }
コード例 #2
0
        public void Format()
        {
            int       rowNum = 0;
            ExportRow newRow = null;
            ExportRow sumRow = null;

            foreach (ExportRow row in this.OriginalRowList)
            {
                if (row.RowType == ExportRowType.Title)
                {
                    newRow = new ExportRow();
                    foreach (string text in row.CellList)
                    {
                        if (text != ExportCell.CellEmpty)
                        {
                            newRow.CellList[this.OriginalColumnList.Count / 2] = text;
                            break;
                        }
                    }
                }
                else if (row.RowType == ExportRowType.Common)
                {
                    newRow = new ExportRow(row);
                    if (rowNum > 0)
                    {
                        if ((this.OriginalRowList[rowNum - 1] as ExportRow).RowType != ExportRowType.Common)
                        {
                            sumRow = new ExportRow(newRow);
                        }
                        else if (sumRow != null)
                        {
                            int colNum = 0;
                            foreach (ExportColumn col in this.OriginalColumnList)
                            {
                                if (col.CellMerge == true)
                                {
                                    if ((this.OriginalRowList[rowNum - 1] as ExportRow).CellList[colNum].ToString().ToUpper() ==
                                        newRow.CellList[colNum].ToString().ToUpper())
                                    {
                                        newRow.CellList[colNum] = "";
                                        sumRow.CellList[colNum] = (this.OriginalRowList[rowNum - 1] as ExportRow).CellList[colNum] + "total";
                                    }
                                }
                                else if (col.CellSummary == true)
                                {
                                    decimal sum = System.Decimal.Parse(sumRow.CellList[colNum].ToString());
                                    decimal add = System.Decimal.Parse(newRow.CellList[colNum].ToString());

                                    sumRow.CellList[colNum] = sum + add;
                                }
                                colNum += 1;
                            }
                        }
                    }
                }
                else if (row.RowType == ExportRowType.Head)
                {
                    newRow = new ExportRow(row);
                }
                else if (row.RowType == ExportRowType.Summary)
                {
                    newRow         = new ExportRow(sumRow);
                    newRow.RowType = ExportRowType.Summary;
                    sumRow         = null;
                }
                else if (row.RowType == ExportRowType.GrandSummary)
                {
                    newRow = new ExportRow();
                    int colNum = 0;
                    foreach (ExportColumn col in this.OriginalColumnList)
                    {
                        if (col.CellMerge == true)
                        {
                            newRow.AddCellText("grand total");
                        }
                        else if (col.CellSummary == true)
                        {
                            decimal sum = 0;
                            foreach (ExportRow sRow in this.FormattedRowList)
                            {
                                if (sRow.RowType == ExportRowType.Summary)
                                {
                                    sum += System.Decimal.Parse(sRow.CellList[colNum].ToString());
                                }
                            }
                            newRow.AddCellText(sum.ToString());
                        }
                        else
                        {
                            newRow.AddCellText(ExportCell.CellEmpty);
                        }
                        colNum += 1;
                    }
                }
                this.FormattedRowList.Add(newRow);
                rowNum += 1;
            }
        }