Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

Copies an area of cells from another Worksheet to cells in this worksheet.

Signature
C#C#
Wiki Markup
{description}
{excerpt}Copies an area of cells from another [Worksheet|Worksheet] to cells in this worksheet. {excerpt}
{signature:C#}
 public Area CopyPaste(Cell destCell, Area sourceArea)
Signature
{signature}{signature:vb.net
vb.net
}
Public Function CopyPaste(ByVal destCell As Cell, ByVal sourceArea As Area) As Area
Parameters

...

A Cell indicating the upper-left cell of the destination area.

...

An area from the source workbook from which to copy.

Returns

An Area object representing the set of cells populated with the copied values.

Remarks

The copied data will overwrite the contents of the cells in this worksheet. The method behaves as if you had passed in CopyPasteProperties object initialized with CopyPasteType.All.

{signature}
{parameters}
{param:destCell}A [Cell|Cell] indicating the upper\-left cell of the destination area.{param}
{param:sourceArea}An area from the source workbook from which to copy.{param}
{returns}An [Area|Area] object representing the set of cells populated with the copied values.{returns}
{remarks}
The copied data will +overwrite+ the contents of the cells in this worksheet.   The method behaves as if you had passed in CopyPasteProperties object initialized with [CopyPasteType.All|CopyPasteProperties.CopyPasteType#All].
{remarks}
{example}{code:csharp|title=C#}

          //--- Open the workbook and worksheet from which we will copy cells.
          Workbook sourceWb = xla.Open("MyDataSource.xls");
          Worksheet sourceWs = sourceWb[0];

          //--- Create the workbook and and get the worksheet
          //--- into which we will paste cells.
          Workbbok destWb = xla.Create("MyNewWorkbook");
          Worksheet destWs = destWb[0];

          //--- Define the area of cells to copy.
          Area srcArea = sourceWs.CreateArea("A1:F20");

          // Paste the data onto the destination worksheet.
          // Copy all supported data types (excluding row height and column width).
          Cell whereToPaste = destSheet["A1"];
          destWs.CopyPaste(whereToPaste, srcArea);
        
{code}
{code:vb.net
|title=vb.net
}

          '--- Open the workbook and worksheet from which we will copy cells.
          Dim sourceWb As Workbook = xla.Open("MyDataSource.xls")
          Dim sourceWs As Worksheet = sourceWb(0)

          '--- Create the workbook and and get the worksheet
          '--- into which we will paste cells.
          Dim destWb As Workbook = xla.Create("MyNewWorkbook")
          Dim destWs As Worksheet = destWb(0)

          '--- Define the area of cells to copy.
          Dim srcArea As Area = sourceWs.CreateArea("A1:F20")

          '--- Paste the data onto the destination worksheet.
          '--- Copy all supported data types (excluding row height and column width).
          Dim whereToPaste As Cell = destSheet("A1")
          destWs.CopyPaste(whereToPaste, srcArea)
        {code}

{example}
Example
Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle