Пример #1
0
        public override IExcelCellHolder GetOrCreateCell(ExcelColumnIndex columnIndex, int rowIndex,
                                                         bool centrized)
        {
            rowIndex.ThrowIfValueIsOutOfRange(nameof(rowIndex), 1, int.MaxValue);
            int columIndexInt = columnIndex.AsInt32();

            columIndexInt.ThrowIfValueIsOutOfRange(nameof(columnIndex), 0, int.MaxValue);

            // Because of using one-based indexing.
            int  fixedRowIndex = rowIndex - 1;
            IRow row           = GetOrCreateRow(fixedRowIndex, centrized);

            ICell cell = row.GetCell(columIndexInt);

            ICell result = cell is null
                ? row.CreateCell(columIndexInt)
                : cell;

            result = centrized
                ? result.Center()
                : result;

            return(new NpoiExcelCellHolder(result));
        }