Exemplo n.º 1
0
        public void MoveColumn(int columnIndexFrom, int columnIndexTo)
        {
            if (this.ColumnLength <= columnIndexFrom || columnIndexFrom < 0)
            {
                CsvGeneric.FromToIndexOutOfException(columnIndexFrom, false, false);
                return;
            }
            if (this.ColumnLength <= columnIndexTo || columnIndexTo < 0)
            {
                CsvGeneric.FromToIndexOutOfException(columnIndexTo, true, false);
                return;
            }
            if (columnIndexFrom == columnIndexTo)
            {
                return;
            }
            string          item  = this._key[columnIndexFrom];
            List <CsvValue> value = this._value[columnIndexFrom].value;

            this._key.RemoveAt(columnIndexFrom);
            this._value.RemoveAt(columnIndexFrom);
            this._key.Insert(columnIndexTo, item);
            CsvColumnList csvColumnList = new CsvColumnList();

            csvColumnList.value = value;
            this._value.Insert(columnIndexTo, csvColumnList);
        }
Exemplo n.º 2
0
        public void InsertColumn(int columnIndex, CsvColumn csvColumn)
        {
            if (columnIndex < 0 || columnIndex > this.ColumnLength)
            {
                CsvGeneric.IndexOutOfException(columnIndex, false);
                return;
            }
            List <CsvValue> list = this.CsvColumnToList(csvColumn);

            if (this.RowLength != list.Count)
            {
                while (this.RowLength != list.Count)
                {
                    if (this.RowLength > list.Count)
                    {
                        list.Add(new CsvValue());
                    }
                    else
                    {
                        this.AddRow();
                    }
                }
            }
            CsvColumnList csvColumnList = new CsvColumnList();

            csvColumnList.value = this.CsvColumnToList(csvColumn);
            if (!this.ContainsColumn(csvColumn, false))
            {
                this._key.Insert(columnIndex, csvColumn.key);
                this._value.Insert(columnIndex, csvColumnList);
            }
            else
            {
                this._key.Add(csvColumn.key);
                this._value.Add(csvColumnList);
            }
        }