コード例 #1
0
 /// <summary>
 /// 移除一個單元格對象
 /// </summary>
 /// <param name="cell">單元格的對象</param>
 public void Remove(ExcelCell cell)
 {
     if (_list.Contains(cell))
     {
         _list.Remove(cell);
     }
 }
コード例 #2
0
        /// <summary>
        /// 創建一個新的行對象
        /// </summary>
        /// <returns></returns>
        public ExcelRow NewRow()
        {
            ExcelRow row = new ExcelRow();

            foreach (ExcelColumn column in _columns)
            {
                ExcelCell cell = new ExcelCell();
                cell.OwningColumnInternal = column;
                cell.OwningRowInternal    = row;
                row.Cells.Add(cell);
            }
            return(row);
        }
コード例 #3
0
        /// <summary>
        /// 新增一個行對象
        /// </summary>
        /// <param name="values">行中的單元格的值</param>
        public void AddRow(object[] values)
        {
            if (values.Length != Columns.Count)
            {
                throw new ArgumentOutOfRangeException("values的長度與列數不相等。");
            }
            ExcelRow row = new ExcelRow();

            for (int i = 0; i < Columns.Count; i++)
            {
                ExcelCell cell = new ExcelCell();
                cell.OwningColumnInternal = Columns[i];
                cell.Value             = values[i];
                cell.OwningRowInternal = row;
                row.Cells.Add(cell);
            }
            Rows.Add(row);
        }
コード例 #4
0
 private void ChangeExcelCell(int index, bool isAdd)
 {
     if (index >= 0 && index < _list.Count)
     {
         if (this[0].ExcelTable != null)
         {
             foreach (ExcelRow row in this[index].ExcelTable.Rows)
             {
                 if (isAdd)
                 {
                     ExcelCell cell = new ExcelCell();
                     cell.OwningRowInternal    = row;
                     cell.OwningColumnInternal = this[index];
                     row.Cells.Add(cell);
                 }
                 else
                 {
                     row.Cells.RemoveAt(index);
                 }
             }
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// 新增一個單元格對象
 /// </summary>
 /// <param name="cell">單元格對象</param>
 public void Add(ExcelCell cell)
 {
     _list.Add(cell);
 }