Spread for ASP.NET 11 Product Documentation
Copy Method (DefaultSheetDataModel)
Example 


FarPoint.Web.Spread Assembly > FarPoint.Web.Spread.Model Namespace > DefaultSheetDataModel Class : Copy Method
Row index of start of range from which to copy
Column index of start of range from which to copy
Row index of start of range to which to copy
Column index of start of range to which to copy
Number of rows to copy
Number of columns to copy
Copies the data from a range of cells to a specified range of cells.
Syntax
'Declaration
 
Public Sub Copy( _
   ByVal fromRow As Integer, _
   ByVal fromColumn As Integer, _
   ByVal toRow As Integer, _
   ByVal toColumn As Integer, _
   ByVal rowCount As Integer, _
   ByVal columnCount As Integer _
) 
'Usage
 
Dim instance As DefaultSheetDataModel
Dim fromRow As Integer
Dim fromColumn As Integer
Dim toRow As Integer
Dim toColumn As Integer
Dim rowCount As Integer
Dim columnCount As Integer
 
instance.Copy(fromRow, fromColumn, toRow, toColumn, rowCount, columnCount)
public void Copy( 
   int fromRow,
   int fromColumn,
   int toRow,
   int toColumn,
   int rowCount,
   int columnCount
)

Parameters

fromRow
Row index of start of range from which to copy
fromColumn
Column index of start of range from which to copy
toRow
Row index of start of range to which to copy
toColumn
Column index of start of range to which to copy
rowCount
Number of rows to copy
columnCount
Number of columns to copy
Exceptions
ExceptionDescription
Specified starting and ending row or row count is not valid
Specified starting and ending column or column count is not valid
Remarks

This method copies the data in a block of cells.

The destination column and row indicate the upper-left cell of the destination block. The contents of the destination block cells are replaced by the copied cells' contents.

Caution: Copying a range of cells pastes them over existing cells. You might want to caution users and have them verify a copy command before overwriting their existing data.

Copying data in the data model copies the data, including the formula, the cell note, and the cell tag. Formatting is not handled by the data model, so calling the Copy method in the data model does not copy formatting, including things such as colors.

Example
This example adds data to the first three columns. In the click event of a button the data is copied from the first two columns and placed in cells in columns two and three.
Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load

If(Me.IsPostBack)Then Return

FpSpread1.ActiveSheetView.RowCount=10
Dim i As Integer
For i=0 To 3
FpSpread1.ActiveSheetView.SetValue(i,0,i)
FpSpread1.ActiveSheetView.SetValue(i,1,i)
FpSpread1.ActiveSheetView.SetValue(i,2,i)
Next
End Sub

Private Sub Button1_Click(ByValsender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click
Dim dm As FarPoint.Web.Spread.Model.DefaultSheetDataModel=CType(FpSpread1.ActiveSheetView.DataModel,FarPoint.Web.Spread.Model.DefaultSheetDataModel)
dm.Copy(0,0,5,1,3,2)
End Sub
private void Page_Load(object sender,System.EventArgs e)
{
if(this.IsPostBack)return;

FpSpread1.ActiveSheetView.RowCount=10;
for(int i=0;i<4;i++)
{
FpSpread1.ActiveSheetView.SetValue(i,0,i);
FpSpread1.ActiveSheetView.SetValue(i,1,i);
FpSpread1.ActiveSheetView.SetValue(i,2,i);
}
}

private void Button1_Click(object sender,System.EventArgs e)
{
FarPoint.Web.Spread.Model.DefaultSheetDataModel dm=(FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.ActiveSheetView.DataModel;
dm.Copy(0,0,5,1,3,2);
}
See Also

Reference

DefaultSheetDataModel Class
DefaultSheetDataModel Members
Clear Method
RemoveColumn Method
RemoveColumns Method
RemoveRow Method
RemoveRows Method
Swap Method
Move Method