private void HandleSingleCellAddress(RangeAddress rangeAddress, ExcelAddressInfo addressInfo) { int col, row; _addressTranslator.ToColAndRow(addressInfo.StartCell, out col, out row); rangeAddress.FromCol = col; rangeAddress.ToCol = col; rangeAddress.FromRow = row; rangeAddress.ToRow = row; }
private void HandleMultipleCellAddress(RangeAddress rangeAddress, ExcelAddressInfo addressInfo) { int fromCol, fromRow; _addressTranslator.ToColAndRow(addressInfo.StartCell, out fromCol, out fromRow); int toCol, toRow; _addressTranslator.ToColAndRow(addressInfo.EndCell, out toCol, out toRow, AddressTranslator.RangeCalculationBehaviour.LastPart); rangeAddress.FromCol = fromCol; rangeAddress.ToCol = toCol; rangeAddress.FromRow = fromRow; rangeAddress.ToRow = toRow; }
public RangeAddress Create(string range) { Require.That(range).Named("range").IsNotNullOrEmpty(); var addressInfo = ExcelAddressInfo.Parse(range); var rangeAddress = new RangeAddress() { Address = range, Worksheet = addressInfo.Worksheet }; if (addressInfo.IsMultipleCells) { HandleMultipleCellAddress(rangeAddress, addressInfo); } else { HandleSingleCellAddress(rangeAddress, addressInfo); } return(rangeAddress); }
private void SetCurrentWorksheet(ExcelAddressInfo addressInfo) { if (addressInfo.WorksheetIsSpecified) { _currentWorksheet = _package.Workbook.Worksheets[addressInfo.Worksheet]; } else if (_currentWorksheet == null) { _currentWorksheet = _package.Workbook.Worksheets.First(); } }