IRONSOFTWAREHOME

C# Edit Excel File

Curtis Chau
Curtis Chau
Updated: August 2, 2026

Edit Excel files in C# using IronXL library which provides simple methods to modify cells, rows, columns, and worksheets programmatically without Excel Interop, reducing errors and complexity.

Developers need precision when modifying Excel files in C# because one error can corrupt entire documents. Simple, efficient code reduces error risk and simplifies programmatic editing or deletion of Excel files. IronXL provides a comprehensive solution for working with Excel files in C# that eliminates Microsoft Office dependencies. This guide covers the steps to edit Excel files in C# correctly and quickly using tested functions.

Quickstart: Edit a Specific Cell Value with IronXL

This example shows how to load an existing Excel file, update a single cell, and save changes using IronXL. Get started in under 5 lines, no Interop required. For complex operations, explore our comprehensive API Reference.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    WorkBook workBook = WorkBook.Load("file.xlsx");
    workBook.GetWorkSheet("Sheet1")["C3"].Value = "Hello IronXL";
    // then save your workbook
    workBook.SaveAs("file.xlsx");
    C#
  3. 3Deploy to test on your live environment

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

Step 1

How Do I Set Up IronXL for C# Excel Editing?

This tutorial uses IronXL, a C# Excel library. Download and install it into your project (free for development) to use these functions. IronXL supports various platforms including Linux and macOS, making it versatile for cross-platform development.

You can either Download IronXL.zip or read more and install via the NuGet package page.

Once installed, let's get started. New to IronXL? Check our Get Started Overview for a comprehensive introduction.


PM > Install-Package IronXL.Excel

Replace x.x.x with the appropriate version number as needed.


How to Tutorial

How Do I Edit Specific Cell Values in Excel?

First, learn how to edit specific cell values of an Excel SpreadSheet. This is one of the most common operations when editing Excel files in C#.

Import the Excel SpreadSheet to modify, then access its WorkSheet. Apply modifications as shown below. IronXL provides multiple ways to access cells, offering flexibility for different programming styles.

using IronXL;

// Load the Excel workbook
WorkBook wb = WorkBook.Load("sample.xlsx");
// Access a specific worksheet
WorkSheet ws = wb.GetWorkSheet("Sheet1");
// Access specific cell by identifying its row and column, then modify its value
ws.Rows[3].Columns[1].Value = "New Value";
// Save changes to the workbook
wb.SaveAs("sample.xlsx");

Here are before and after screenshots of Excel SpreadSheet sample.xlsx:

BeforeAfter
Excel spreadsheet with highlighted cell showing 'France' in Country column, demonstrating cell selection for editingExcel cell B4 showing 'New Value' with blue selection border after editing cell content

Notice how simple it is to modify the Excel SpreadSheet value. This approach works well when updating specific data points without affecting the rest of your spreadsheet.

An alternative way to edit specific cell values by cell address:

// Alternative way to access specific cell and apply changes
ws["B4"].Value = "New Value";

How Do I Edit Full Row Values in Excel?

Edit full row values of an Excel SpreadSheet with a static value easily. This operation helps when updating entire records at once, such as resetting data or applying bulk updates. For complex row operations, explore adding rows and columns.

using IronXL;

WorkBook wb = WorkBook.Load("sample.xlsx");
WorkSheet ws = wb.GetWorkSheet("Sheet1");
// Setting a static value for the entire row
ws.Rows[3].Value = "New Value";
wb.SaveAs("sample.xlsx");

See the screenshots of sample.xlsx below:

BeforeAfter
Excel spreadsheet with row 4 highlighted showing Government segment data for France with Montana productExcel table showing new row with 'New Value' entries added across all columns in a sales data spreadsheet

Edit values of a specific range within a row using the range function:

// Editing a specific range of a row
ws["A3:E3"].Value = "New Value";

When working with ranges, you might also need selecting ranges for advanced operations like sorting or applying formulas.


How Do I Edit Full Column Values in Excel?

Edit full columns of Excel SpreadSheet values with a single value easily. This works well for scenarios like updating currency columns, applying new tax rates, or standardizing data formats across an entire column.

using IronXL;

WorkBook wb = WorkBook.Load("sample.xlsx");
WorkSheet ws = wb.GetWorkSheet("Sheet1");
// Setting a static value for the entire column
ws.Columns[1].Value = "New Value";
wb.SaveAs("sample.xlsx");

This produces our sample.xlsx spreadsheet as shown:

BeforeAfter
Excel spreadsheet with Country column highlighted in blue, showing business data across segments and countriesExcel spreadsheet showing column B filled with 'New Value' text after bulk column edit operation

How Do I Edit a Full Row with Dynamic Values?

IronXL allows editing specific rows with dynamic values. Edit a full row by assigning dynamic values for each cell. This approach works well when importing data from databases or other sources requiring unique values per cell. See the example:

using IronXL;
using System.Linq;

WorkBook wb = WorkBook.Load("sample.xlsx");
WorkSheet ws = wb.GetWorkSheet("Sheet1");
for (int i = 0; i < ws.Columns.Count(); i++)
{
    // Assign dynamic values to each cell in the row
    ws.Rows[3].Columns[i].Value = "New Value " + i.ToString();
}
wb.SaveAs("sample.xlsx");

The table below shows screenshots of Excel SpreadSheet sample.xlsx from this output:

BeforeAfter
Excel spreadsheet with row 4 highlighted showing Enterprise segment data before editing with dynamic valuesExcel sheet with row 4 showing 'New Value 0-4' placeholder text after dynamic row editing operation

How Do I Edit a Full Column with Dynamic Values?

Edit specific columns with dynamic values simply. This technique helps populate columns with sequential data like ID numbers, dates, or calculated values based on row position.

using IronXL;
using System.Linq;

WorkBook wb = WorkBook.Load("sample.xlsx");
WorkSheet ws = wb.GetWorkSheet("Sheet1");
for (int i = 0; i < ws.Rows.Count(); i++)
{
    // Skip the first row if it's used as a header
    if (i == 0)
        continue;
    // Assign dynamic values to each cell in the column
    ws.Rows[i].Columns[1].Value = "New Value " + i.ToString();
}
wb.SaveAs("sample.xlsx");

With the table results of sample.xlsx below:

BeforeAfter
Excel spreadsheet with Country column highlighted, showing business data across segments and productsExcel sheet showing Country column filled with dynamic placeholder values 'New Value 1-9' after bulk edit operation

How Do I Replace Spreadsheet Values in Excel?

Replace any value type with an updated value in an Excel SpreadSheet using the Replace function. Use this function to replace Excel SpreadSheet data in any required situation. This works well for data cleaning, updating terminology, or correcting systematic errors across spreadsheets.

How Do I Replace Values in an Entire Worksheet?

To replace a specific value throughout a complete Excel SpreadSheet with an updated value, access the WorkSheet ws (same as above examples) and apply the Replace function:

// Replace a specific value in the entire worksheet
ws.Replace("old value", "new value");

This function replaces old value with new value in a complete Excel SpreadSheet. It's a powerful feature for bulk updates that would otherwise require manual find-and-replace operations in Excel.

Remember to save the file after any change, as shown in the examples above. For more information on saving and exporting Excel files, see our guide on converting spreadsheet file types.

How Do I Replace Values in a Specific Row?

To make changes to a specific row instead of the whole worksheet, use this code:

// Replace a specific value in a specific row
ws.Rows[2].Replace("old value", "new value");

The above code replaces old value with new value only in row number 2. The rest of the WorkSheet remains unchanged.

How Do I Replace Values in a Row Range?

Replace values within a specific range as follows:

// Replace specific values in a row range
ws["From Cell Address : To Cell Address"].Replace("old value", "new value");

To replace an old value with a new value in the range from B4 to E4 of row number 4, write:

ws["B4:E4"].Replace("old value", "new value");

How Do I Replace Values in a Specific Column?

Replace values of a specific column while keeping the rest of the worksheet unchanged:

// Replace specific values in a column
ws.Columns[1].Replace("old value", "new value");

The above code replaces old value with new value only for column number 1.

How Do I Replace Values in a Column Range?

Use the range function to replace within a range of a specific column:

// Replace specific values in a column range
ws["B5:B10"].Replace("old value", "new value");

The above code replaces old value with new value only within the range from B5 to B10 for column B.


How Do I Remove a Row from Excel Worksheet?

IronXL provides a simple function to remove a specific row of an Excel SpreadSheet. This functionality helps when cleaning data or removing outdated records from spreadsheets. See the example:

using IronXL;

WorkBook wb = WorkBook.Load("sample.xlsx");
WorkSheet ws = wb.GetWorkSheet("Sheet1");
// Remove a specific row
ws.Rows[3].RemoveRow();
wb.SaveAs("sample.xlsx");

The above code removes row number 3 of SpreadSheet sample.xlsx as shown in the following table:

BeforeAfter
Excel worksheet with row 4 highlighted showing Government segment data for Canada before row removal operationExcel worksheet with row 4 highlighted in blue showing the result after row removal operation

How Do I Remove a Worksheet from Excel File?

To remove a complete WorkSheet of an Excel file, use the following method. This helps when consolidating data or removing temporary worksheets used for calculations. For more information on managing worksheets, see our guide on managing worksheets.

// Remove a worksheet by its index
wb.RemoveWorkSheet(1); // by sheet indexing

WorkSheet WorkSheet is the WorkSheet, same as in the above examples. To remove a worksheet by name:

// Remove a worksheet by its name
wb.RemoveWorkSheet("Sheet1"); //by sheet name

IronXL includes many more functions for easily performing any type of editing and deletion in Excel SpreadSheets. Explore additional features like creating Excel charts, applying conditional formatting, or working with formulas. Contact our dev team with any questions about using IronXL in your project.


Library Quick Access

IronXL Library Documentation

Explore the full capabilities of IronXL C# Library with various functions for editing, deleting, styling, and perfecting your Excel workbooks.

IronXL Library Documentation

Frequently Asked Questions

What is IronXL and how does it help in editing Excel files in C#?

IronXL is a C# Excel library that simplifies the process of editing Excel files programmatically without using Excel Interop. It provides simple methods to modify cells, rows, columns, and worksheets, reducing errors and complexity.

How can I edit a specific cell value using IronXL?

To edit a specific cell value using IronXL, load the Excel file into a WorkBook object, access the desired worksheet, modify the cell's value, and save the changes. This can be done in under 5 lines of code, without needing Excel Interop.

Can I edit entire row values in an Excel spreadsheet with IronXL?

Yes, with IronXL, you can easily edit entire row values in an Excel spreadsheet, either by setting a static value for all cells in the row or by using dynamic values for updated records.

How do I edit entire column values with IronXL?

IronXL allows editing entire column values with a static value efficiently, making it suitable for operations such as updating tax rates or standardizing data formats across columns.

Is it possible to replace values in an Excel worksheet using IronXL?

Yes, IronXL provides a Replace function that allows you to update specific values throughout an entire worksheet or in designated rows, columns, and ranges.

What are the steps to remove a row from an Excel worksheet using IronXL?

To remove a row from an Excel worksheet using IronXL, load the workbook, access the worksheet, and use the RemoveRow method on the desired row. Finally, save the workbook.

How can I remove a worksheet from an Excel file with IronXL?

You can remove a worksheet from an Excel file using IronXL either by its index or name with the RemoveWorkSheet method. This is useful for cleaning up unnecessary data.

Does IronXL support cross-platform development for Excel file manipulation?

Yes, IronXL supports various platforms including Windows, Linux, and macOS, making it versatile for cross-platform development.

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