IRONSOFTWAREHOME

How to Copy Cells in C# with IronXL

Curtis Chau
Curtis Chau
Updated: August 2, 2026

IronXL enables copying cells, ranges, rows, or columns in Excel spreadsheets using a single Copy method that preserves all formatting and styling while duplicating data between any locations or worksheets.

The "Copy cell" feature duplicates cell contents and pastes them into other cells. It replicates data, formulas, formatting, and other attributes within the worksheet. Whether creating spreadsheets from scratch or loading existing Excel files, the copy functionality is essential for efficient data manipulation.

Quickstart: Copy a Column or Range in One Line

Copy entire ranges - single cells, rows, columns, or blocks - from one sheet to another using one method call. The Copy function retains styling and formatting while making Excel automation fast and simple.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    workSheet.GetColumn(0).Copy(workBook.GetWorkSheet("Sheet1"), "H1");
  3. 3Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

How Do I Copy a Single Cell in Excel?

To copy a selected cell's content, use the Copy method. Pass the worksheet object as the first parameter and the starting position as the second parameter. The Copy method retains all styling including font and size, background patterns and colors, and borders and alignment.

using IronXL;

WorkBook workBook = WorkBook.Load("sample.xlsx");
WorkSheet workSheet = workBook.GetWorkSheet("Sheet1");

// Copy cell content
workSheet["A1"].Copy(workBook.GetWorkSheet("Sheet1"), "B3");

workBook.SaveAs("copySingleCell.xlsx");

What Formatting Is Preserved When Copying?

The Copy method preserves all cell properties including:

  • Cell values and formulas
  • Number formats (currency, percentage, dates)
  • Font styling (typeface, size, bold, italic, color)
  • Cell borders and background colors
  • Text alignment (horizontal and vertical)
  • Cell protection settings

This comprehensive preservation ensures copied cells maintain their original appearance and functionality, similar to using Ctrl+C and Ctrl+V in Microsoft Excel.

Spreadsheet showing cell A1 selected with arrow pointing to cell B3 containing copied value, demonstrating single cell copy

Why Does the Copy Method Take Two Parameters?

The Copy method requires two parameters for precise control:

  1. Worksheet parameter: Specifies the destination worksheet (same or different within the workbook)
  2. Address parameter: Defines the starting cell position for pasted content

This design allows flexible copying within the same sheet or across different sheets, ideal for creating summary reports or consolidating data from multiple sources.

When Should I Use Single Cell Copy vs Range Copy?

Choose single cell copy when:

  • Duplicating individual values or formulas
  • Copying header cells or labels
  • Replicating specific calculated results
  • Working with summary values

Use range copy when:

  • Moving entire data tables
  • Duplicating multiple related cells
  • Copying complete rows or columns
  • Preserving data relationships

How Can I Copy Multiple Cells or Ranges?

Like the Clear method, Copy is available in the Range class, allowing execution on any range size. When selecting ranges, IronXL provides flexible copying options:

  • Copy a single cell (C10):

    workSheet["C10"].Copy(workBook.GetWorkSheet("Sheet1"), "B13");
  • Copy a column (A):

    workSheet.GetColumn(0).Copy(workBook.GetWorkSheet("Sheet1"), "H1");
  • Copy a row (4):

    workSheet.GetRow(3).Copy(workBook.GetWorkSheet("Sheet1"), "A15");
  • Copy a two-dimensional range (D6:F8):

    workSheet["D6:F8"].Copy(workBook.GetWorkSheet("Sheet1"), "H17");
Please note: The second parameter accepts an address location that marks the starting point of data entry. The copied data will start from that address and spread rightward and downward.
using IronXL;

WorkBook workBook = WorkBook.Load("sample.xlsx");
WorkSheet workSheet = workBook.GetWorkSheet("Sheet1");

// Copy a single cell(C10)
workSheet["C10"].Copy(workBook.GetWorkSheet("Sheet1"), "B13");

// Copy a column(A)
workSheet.GetColumn(0).Copy(workBook.GetWorkSheet("Sheet1"), "H1");

// Copy a row(4)
workSheet.GetRow(3).Copy(workBook.GetWorkSheet("Sheet1"), "A15");

// Copy a two-dimensional range(D6:F8)
workSheet["D6:F8"].Copy(workBook.GetWorkSheet("Sheet1"), "H17");

workBook.SaveAs("copyCellRange.xlsx");

What Happens When the Destination Range Is Too Small?

IronXL automatically handles size differences:

  • The destination parameter specifies only the top-left starting cell
  • The entire source range copies regardless of destination size
  • Existing data in the destination area gets overwritten
  • The copy operation expands to accommodate all source data

For example, copying a 3x3 range to cell B1 populates cells B1:D3, overwriting any existing content.

How Do Row and Column References Work?

IronXL uses zero-based indexing for rows and columns with GetRow() and GetColumn() methods:

  • GetColumn(0) refers to column A
  • GetColumn(1) refers to column B
  • GetRow(0) refers to row 1
  • GetRow(3) refers to row 4

This indexing aligns with standard C# array conventions.

Why Use GetColumn() and GetRow() Methods?

GetColumn() and GetRow() methods offer:

  • Performance: More efficient for entire rows or columns
  • Clarity: Makes code intent clearer
  • Flexibility: Returns a Range object supporting all range operations
  • Convenience: No need to calculate end cells for full selections

These methods excel when creating reports requiring full column copies or when duplicating row templates.

Excel copy operations showing arrows from source ranges A1:F10 to destination cells with highlighted copied data

How Do I Copy Cells Between Different Worksheets?

The first parameter accepts a worksheet object, enabling copy and paste across different worksheets. Pass a different worksheet object as the first parameter. This functionality proves essential when managing multiple worksheets or creating summary sheets from detailed data.

Please note: In the following example, the first parameter of the Copy method is the "Sheet2" worksheet: workBook.GetWorksheet("Sheet2")
using IronXL;

WorkBook workBook = WorkBook.Load("sample.xlsx");
WorkSheet workSheet = workBook.GetWorkSheet("Sheet1");

// Copy cell content
workSheet["A1"].Copy(workBook.GetWorkSheet("Sheet2"), "B3");

workBook.SaveAs("copyAcrossWorksheet.xlsx");

What Are Common Cross-Worksheet Copy Scenarios?

Cross-worksheet copying frequently serves these scenarios:

  1. Creating Summary Sheets: Copy key metrics from detail sheets into dashboards
  2. Template Replication: Copy formatted templates to new worksheets
  3. Data Consolidation: Gather data from departmental sheets into master sheets
  4. Report Generation: Copy filtered results to separate reporting worksheets
  5. Backup Operations: Duplicate critical data to backup sheets

When working with formulas that reference other cells, IronXL automatically adjusts relative references based on the new location while maintaining absolute references.

When Should I Copy to a New Worksheet vs Existing?

Copy to a new worksheet when:

  • Creating periodic reports (daily, weekly, monthly)
  • Isolating processed data from raw data
  • Building analysis worksheets from source data
  • Generating user-specific data views

Copy to an existing worksheet when:

  • Appending data to ongoing logs
  • Updating dashboard sections
  • Consolidating multiple data sources
  • Maintaining historical records

For complex scenarios involving multiple sheets, consider using IronXL's ability to work with DataSets and DataTables for sophisticated data manipulation.

How to Handle Worksheet Naming Conflicts?

Ensure proper worksheet management when copying between worksheets:

// Check if worksheet exists before copying
if (workBook.GetWorkSheet("TargetSheet") == null)
{
    workBook.CreateWorkSheet("TargetSheet");
}

// Safe copy operation
WorkSheet targetSheet = workBook.GetWorkSheet("TargetSheet");
sourceSheet["A1:Z100"].Copy(targetSheet, "A1");

This approach prevents runtime errors and ensures successful copy operations, especially important when automating Excel processes in production environments.

Frequently Asked Questions

How can I copy cells in Excel using C# with IronXL?

You can use IronXL's `Copy` method to duplicate cell content. This method allows you to duplicate cells, ranges, rows, or columns while retaining all data, formulas, and formatting, enabling efficient Excel automation.

What is the significance of the `Copy` method requiring two parameters?

The `Copy` method in IronXL requires two parameters: the worksheet object and the starting position. This ensures precise control over the destination, allowing you to copy within the same sheet or across different sheets, ideal for data consolidation.

What types of formatting are preserved when copying cells with IronXL?

IronXL's `Copy` method preserves all attributes including cell values, formulas, number formats, font styling, borders, background colors, text alignment, and cell protection settings, ensuring the copied content retains its original functionality and appearance.

When should I use a single cell copy versus a range copy in IronXL?

You should use a single cell copy when duplicating individual values, formulas, or specific calculated results. Use range copy for moving entire data tables, multiple related cells, or entire rows or columns while preserving data relationships.

How does IronXL handle copying across different worksheets?

IronXL allows copying across worksheets by accepting a different worksheet object as the first parameter in the `Copy` method. This feature is useful for managing multiple worksheets and creating summary sheets from detailed data.

What happens if the destination range is smaller than the source when copying cells with IronXL?

When the destination range is smaller, IronXL's `Copy` function still accommodates the full source range by overwriting any existing data in the destination area, expanding as needed to fit all copied data.

Why might I choose to copy to a new worksheet rather than an existing one?

Copying to a new worksheet is recommended for creating periodic reports, isolating processed data, building analysis sheets, and generating user-specific views. This ensures data separation and clarity in reporting.

How do row and column references work in IronXL?

IronXL uses zero-based indexing where `GetColumn(0)` refers to column A, and `GetRow(0)` refers to row 1. This aligns with C# array conventions, making it intuitive for developers familiar with standard C# practices.

What are common scenarios for cross-worksheet copying with IronXL?

Cross-worksheet copying in IronXL is commonly used for creating summary sheets, replicating templates to new sheets, consolidating data from multiple sources, generating reports, and performing backup operations of critical data.

How does IronXL handle worksheet naming conflicts during copy operations?

IronXL manages worksheet naming conflicts by allowing you to check for and create target sheets if they don't exist, ensuring safe copy operations without runtime errors, which is crucial for automating Excel processes.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required