Beispiel #1
0
 public static ICell GetOrCreateCol(this IRow row, int col)
 {
     ICell result = row.GetCell(col);
     if (result == null)
     {
         result = row.CreateCell(col);
     }
     return result;
 }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="row"></param>
        /// <param name="index"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static ICell CreateCell(this IRow row, int index, Action<ICell> callback)
        {
            if (row == null)
            {
                throw new ArgumentNullException(nameof(row));
            }

            if (index < 0)
            {
                throw new ArgumentException("单元格索引不能小于0!", nameof(index));
            }

            var cell = row.CreateCell(index);

            callback(cell);

            return cell;
        }
Beispiel #3
0
 static ICell GetOrCreateCell(this IRow sheetRow, int colIndex)
 {
     ICell cell = sheetRow.GetCell(colIndex);
     if (cell == null)
         cell = sheetRow.CreateCell(colIndex);
     return cell;
 }
 /// <summary>
 /// Creates a cell and sets its formula.
 /// </summary>
 /// <param name="row">The row.</param>
 /// <param name="column">The column.</param>
 /// <param name="formula">The formula to set.</param>
 /// <returns>The newly created cell.</returns>
 public static ICell SetFormula(this IRow row, int column, string formula)
 {
     var cell = row.CreateCell(column);
     cell.SetCellFormula(formula);
     return cell;
 }
 /// <summary>
 /// Creates a cell and sets it to a string value.
 /// </summary>
 /// <param name="row">The row.</param>
 /// <param name="column">The column.</param>
 /// <param name="value">The value to set.</param>
 /// <returns>The newly created cell.</returns>
 public static ICell SetCell(this IRow row, int column, string value)
 {
     var cell = row.CreateCell(column);
     cell.SetCellValue(value);
     return cell;
 }
Beispiel #6
0
 public static HSSFCell CreateCell(this HSSFRow row, string ColumnAlphaBet)
 {
     return row.CreateCell(Col(ColumnAlphaBet));
 }
 public static ICell CreateCell(this IRow row, int colId, ICellStyle cellStyle)
 {
     ICell cell = row.CreateCell(colId);
     cell.CellStyle = cellStyle;
     return cell;
 }