Spread Windows Forms 9.0 Product Documentation
CopyRange(Int32,Int32,Int32,Int32,Int32,Int32,Boolean) Method
Example 


Row index of top-left cell in block to copy
Column index of top-left cell in block to copy
Row index of top-left cell in destination
Column index of top-left cell in destination
Number of rows in the block
Number of columns in the block
Whether only the data is copied, or the data and formatting
Copies the data, formatting, formulas, and notes from a block of cells on the sheet to a new location.
Syntax
'Declaration
 
Public Sub CopyRange( _
   ByVal fromRow As Integer, _
   ByVal fromColumn As Integer, _
   ByVal toRow As Integer, _
   ByVal toColumn As Integer, _
   ByVal rowCount As Integer, _
   ByVal columnCount As Integer, _
   ByVal dataOnly As Boolean _
) 
'Usage
 
Dim instance As SheetView
Dim fromRow As Integer
Dim fromColumn As Integer
Dim toRow As Integer
Dim toColumn As Integer
Dim rowCount As Integer
Dim columnCount As Integer
Dim dataOnly As Boolean
 
instance.CopyRange(fromRow, fromColumn, toRow, toColumn, rowCount, columnCount, dataOnly)
public void CopyRange( 
   int fromRow,
   int fromColumn,
   int toRow,
   int toColumn,
   int rowCount,
   int columnCount,
   bool dataOnly
)

Parameters

fromRow
Row index of top-left cell in block to copy
fromColumn
Column index of top-left cell in block to copy
toRow
Row index of top-left cell in destination
toColumn
Column index of top-left cell in destination
rowCount
Number of rows in the block
columnCount
Number of columns in the block
dataOnly
Whether only the data is copied, or the data and formatting
Exceptions
ExceptionDescription
System.InvalidOperationException Operation is not valid; cannot copy entire sheet of cells
System.InvalidOperationException Operation is not valid; cannot copy entire columns over partial columns
System.InvalidOperationException Operation is not valid; cannot copy entire rows over partial rows
System.InvalidOperationException Operation is not valid; cannot copy a range of cells over part of a spanned cell
Example
This example uses the CopyRange method.
fpSpread1.Sheets[0].Cells[0, 0].Text = "test";
fpSpread1.Sheets[0].Cells[0, 1].Text = "B";
fpSpread1.Sheets[0].Cells[0, 2].Text = "C";
fpSpread1.Sheets[0].Cells[0, 2].BackColor = Color.Crimson;

private void button1_Click(object sender, EventArgs e)
        {
            fpSpread1.Sheets[0].CopyRange(0, 0, 5, 0, 3, 3, false);               
        }
FpSpread1.Sheets(0).Cells(0, 0).Text = "test"
FpSpread1.Sheets(0).Cells(0, 1).Text = "B"
FpSpread1.Sheets(0).Cells(0, 2).Text = "C"
FpSpread1.Sheets(0).Cells(0, 2).BackColor = Color.Crimson

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        FpSpread1.Sheets(0).CopyRange(0, 0, 5, 0, 3, 3, False)
End Sub
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

SheetView Class
SheetView Members

 

 


Copyright © GrapeCity, inc. All rights reserved.