Search code examples
c#spreadsheetgear

Pastespecial Range from one workbook to another using SpreadsheetGear


daughter.Worksheets["DataLoad"].Range[1, 1, t.APIs.Count, 1].EntireRow.Copy(Master.Worksheets[DataLoad.Name].Range[rowIndex, 1, rowIndex + t.APIs.Count, 1].EntireRow);

copies all formulas and formats and pastes into the range in the .Copy overload I cant seem to figure out how to paste just values or just values and formats. My attempt:

daughter.Worksheets["DataLoad"].Range[1, 1, t.APIs.Count, 1].EntireRow.Copy(Master.Worksheets[DataLoad.Name].Range[rowIndex, 1, rowIndex + t.APIs.Count, 1].EntireRow, PasteType.ValuesAndNumberFormats)

gives the error no overload for method copy takes 2 arguments. Ive been looking online for awhile now and I cant seem to figure out what should be a trivial solution.


Solution

  • Please refer to the documentation for IRange.Copy(...). You should find an overloaded option which accepts 5 arguments, the second of which is a PasteType enumeration that allows you to choose what aspects of the range should be copied. Example:

    srcRange.Copy(destRange, PasteType.Values, PasteOperation.None, false, false);