Cells.CopyRows

CopyRows(Cells, int, int, int)

Copies data and formats of some whole rows.

public void CopyRows(Cells sourceCells, int sourceRowIndex, int destinationRowIndex, int rowNumber)
ParameterTypeDescription
sourceCellsCellsSource Cells object contains data and formats to copy.
sourceRowIndexInt32Source row index.
destinationRowIndexInt32Destination row index.
rowNumberInt32The copied row number.

Examples

// Called: cells.CopyRows(sourcecells, 0,
public void Cells_Method_CopyRows()
{
         
    Workbook book = new Workbook(Constants.sourcePath + "example.xlsx");
    Workbook book2 = new Workbook(Constants.sourcePath + "example.xlsx");

    //Get the first worksheet 
    Worksheet sheet = book2.Worksheets[0];

    Cells cells, sourcecells;

    cells = book.Worksheets[0].Cells;
    sourcecells = sheet.Cells;

    // copy book2's contents to book's sheet at the end 
    cells.CopyRows(sourcecells, 0,
            cells.MaxDisplayRange.RowCount + 2,
            sourcecells.MaxDisplayRange.RowCount);

    Assert.AreEqual(book.Worksheets[0].SparklineGroups.Count, 2);
}

See Also


CopyRows(Cells, int, int, int, CopyOptions)

Copies data and formats of some whole rows.

public void CopyRows(Cells sourceCells0, int sourceRowIndex, int destinationRowIndex, 
    int rowNumber, CopyOptions copyOptions)
ParameterTypeDescription
sourceCells0CellsSource Cells object contains data and formats to copy.
sourceRowIndexInt32Source row index.
destinationRowIndexInt32Destination row index.
rowNumberInt32The copied row number.
copyOptionsCopyOptionsThe copy options.

Examples

// Called: aWkAsp.Worksheets[0].Cells.CopyRows(aWkAsp.Worksheets[0].Cells, 4, 5, 1, options);
public void Cells_Method_CopyRows()
{

    Aspose.Cells.Workbook aWkAsp = new Aspose.Cells.Workbook(Constants.sourcePath + "example.xls");
    Assert.AreEqual(aWkAsp.Worksheets[0].Hyperlinks.Count,2);

    aWkAsp.Worksheets[0].Cells.InsertRows(5, 1);
    aWkAsp.Worksheets[0].Cells.CopyRows(aWkAsp.Worksheets[0].Cells, 4, 5, 1);
    Assert.AreEqual(aWkAsp.Worksheets[0].Hyperlinks.Count,4);

    aWkAsp = new Aspose.Cells.Workbook(Constants.sourcePath + "example.xls");
    Assert.AreEqual(aWkAsp.Worksheets[0].Hyperlinks.Count, 2);
    CopyOptions options = new CopyOptions();
    options.ExtendToAdjacentRange = true;
    aWkAsp.Worksheets[0].Cells.InsertRows(5, 1);
    aWkAsp.Worksheets[0].Cells.CopyRows(aWkAsp.Worksheets[0].Cells, 4, 5, 1, options);
    Assert.AreEqual(aWkAsp.Worksheets[0].Hyperlinks.Count, 2);

}

See Also


CopyRows(Cells, int, int, int, CopyOptions, PasteOptions)

Copies data and formats of some whole rows.

public void CopyRows(Cells sourceCells0, int sourceRowIndex, int destinationRowIndex, 
    int rowNumber, CopyOptions copyOptions, PasteOptions pasteOptions)
ParameterTypeDescription
sourceCells0CellsSource Cells object contains data and formats to copy.
sourceRowIndexInt32Source row index.
destinationRowIndexInt32Destination row index.
rowNumberInt32The copied row number.
copyOptionsCopyOptionsThe copy options.
pasteOptionsPasteOptionsthe options of pasting.

See Also