/// <summary> /// Duplicates the row down by the specified offset. /// </summary> /// <param name="headerRangeName">Name of the header range.</param> /// <param name="columnOffset">The column offset from the header.</param> /// <param name="worksheet">Worksheet that contains the range name.</param> public void DuplicateColumnOver(string headerRangeName, int columnOffset, string worksheet = "") { if (_xlWorkbook == null) { return; } _xlRange = getRangeByName(headerRangeName, worksheet).Offset[0, columnOffset].EntireColumn; ExcelWrapper.RangeCopyEntireColumnAttempts(_xlRange, columnCopyOffset: 1); }
/// <summary> /// Duplicates the row down by the specified offset. /// </summary> /// <param name="headerRangeName">Name of the header range.</param> /// <param name="rowOffset">The row offset from the header.</param> /// <param name="worksheet">Worksheet that contains the range name.</param> public void DuplicateRowDown(string headerRangeName, int rowOffset, string worksheet = "") { if (_xlWorkbook == null) { return; } _xlRange = getRangeByName(headerRangeName, worksheet).Offset[rowOffset].EntireRow; ExcelWrapper.RangeCopyEntireRowAttempts(_xlRange, rowCopyOffset: 1); }
/// <summary> /// Clears formulas and values from the column. /// </summary> /// <param name="headerRangeName">Name of the header range.</param> /// <param name="columnOffset">The column offset from the header.</param> /// <param name="worksheet">Worksheet that contains the range name.</param> public void ClearColumnContents(string headerRangeName, int columnOffset, string worksheet = "") { if (_xlWorkbook == null) { return; } _xlRange = getRangeByName(headerRangeName, worksheet).Offset[0, columnOffset].EntireRow; ExcelWrapper.RangeClearContents(_xlRange); }
/// <summary> /// Clears formulas, values and formatting from the row range. /// </summary> /// <param name="headerRangeName">Name of the header range.</param> /// <param name="rowOffset">The row offset from the header.</param> /// <param name="worksheet">Worksheet that contains the range name.</param> public void ClearRow(string headerRangeName, int rowOffset, string worksheet = "") { if (_xlWorkbook == null) { return; } _xlRange = getRangeByName(headerRangeName, worksheet).Offset[rowOffset].EntireRow; ExcelWrapper.RangeClear(_xlRange); }
/// <summary> /// Writes the value in the cell at the specified offset. /// </summary> /// <param name="rangeName">Name of the single cell range.</param> /// <param name="rangeValue">The range value.</param> /// <param name="rowOffset">The row offset from the header.</param> /// <param name="columnOffset">The column offset from the header.</param> /// <param name="worksheet">Worksheet that contains the range name.</param> public void WriteValue(string rangeName, string rangeValue, int rowOffset = 0, int columnOffset = 0, string worksheet = "") { if (_xlWorkbook == null) { return; } _xlRange = getRangeByName(rangeName, worksheet).Offset[rowOffset, columnOffset].Cells; // Only do this to ranges that are single cells. if (_xlRange == null || _xlRange.Count > 1) { return; } //xlRange.Value = rangeValue; ExcelWrapper.RangeWriteValue(_xlRange, rangeValue); }
/// <summary> /// Initializes the specified open workbook. /// </summary> /// <param name="openWorkbook">if set to <c>true</c> [open workbook].</param> private void Initialize(bool openWorkbook) { if (_xlApp == null) { return; } if (openWorkbook) { _xlWorkbook = ExcelWrapper.AppWorkbooksOpen(_xlApp, Path); } else { string fileName = System.IO.Path.GetFileName(Path); foreach (Excel.Workbook workbook in _xlApp.Workbooks) { if (workbook.Name == fileName) { _xlWorkbook = workbook; break; } } } if (_xlWorkbook == null) { return; } foreach (Excel._Worksheet worksheet in _xlWorkbook.Sheets) { Worksheets.Add(worksheet); } foreach (Excel.Name name in _xlWorkbook.Names) { Names.Add(name); } }