Ejemplo n.º 1
0
 /// <summary>
 /// 移除一个单元格
 /// </summary>
 /// <param name="cell">单元格对象</param>
 public void Remove(ExcelCell cell)
 {
     if (_list.Contains(cell))
     {
         _list.Remove(cell);
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 新增一个单元格对象
 /// </summary>
 /// <param name="cell">单元格对象</param>
 public void Add(ExcelCell cell)
 {
     _list.Add(cell);
 }