In this tutorial, I'll show you how to update data in excel file using EPPlus library in C#.NET

We will use the EPPlus library to read and update data in the excel file

If you don't have the EPPlus library installed already in your project. You can download and install the EPPlus from Manage Nuget Packages, then use the following code to edit data in your excel file

// path of your excel file
string path = "C://sample.xlsx";
FileInfo fileInfo = new FileInfo(path);
ExcelPackage package = new ExcelPackage(fileInfo);
ExcelWorksheet worksheet = package.Workbook.Worksheets.FirstOrDefault();//Sheet 1
// get number of rows in the sheet
int rows = worksheet.Dimension.Rows;
// using loop through the worksheet
for (int i = 1; i <= rows; i++)
    // replace your data
    if(worksheet.Cells[i, 5].Value.ToString() == "c# code")
        worksheet.Cells[i, 5].Value = "";
//update data in excel file

After we loop through our spreadsheet and we replace all occurrences of the 'c# code' with ''