Spread ASP.NET 6.0 Product Documentation
Copy Method
See Also  Example Send Feedback
FarPoint.Web.Spread Assembly > FarPoint.Web.Spread.Model Namespace > DefaultSheetDataModel Class : Copy Method


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

Glossary Item Box

Copies the data from a range of cells to a specified range of cells.

Syntax

Visual Basic (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 _
) 
Visual Basic (Usage)Copy Code
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)
C# 
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
System.ArgumentException Specified starting and ending row or row count is not valid
System.ArgumentException 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.
Visual BasicCopy Code
PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load

If(Me.IsPostBack)ThenReturn

FpSpread1.ActiveSheetView.RowCount=10
DimiAsInteger
Fori=0To3
FpSpread1.ActiveSheetView.SetValue(i,0,i)
FpSpread1.ActiveSheetView.SetValue(i,1,i)
FpSpread1.ActiveSheetView.SetValue(i,2,i)
Next

EndSub

PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
DimdmAsFarPoint.Web.Spread.Model.DefaultSheetDataModel=CType(FpSpread1.ActiveSheetView.DataModel,FarPoint.Web.Spread.Model.DefaultSheetDataModel)
dm.Copy(0,0,5,1,3,2)
EndSub
C#Copy Code
privatevoidPage_Load(objectsender,System.EventArgse)
{
if(this.IsPostBack)return;

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

privatevoidButton1_Click(objectsender,System.EventArgse)
{
FarPoint.Web.Spread.Model.DefaultSheetDataModeldm=(FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.ActiveSheetView.DataModel;
dm.Copy(0,0,5,1,3,2);
}

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2002-2012 GrapeCity, Inc. All Rights Reserved.