using System.Collections.Generic;
using System.Threading.Tasks;
using NetOffice.ExcelApi;
public static void Main(string[] args)
Dictionary<string, string> listErrorExcel = new Dictionary<string, string>();
listErrorExcel.Add("-2146826288", "#NULL!");
listErrorExcel.Add("-2146826281", "#DIV/0!");
listErrorExcel.Add("-2146826273", "#VALUE!");
listErrorExcel.Add("-2146826265", "#REF!");
listErrorExcel.Add("-2146826259", "#NAME?");
listErrorExcel.Add("-2146826252", "#NUM!");
listErrorExcel.Add("-2146826246", "#N/A");
using (var excelApplication = new NetOffice.ExcelApi.Application())
excelApplication.DisplayAlerts = false;
string fichierCible = "d:\\test.xlsx";
Workbook book = excelApplication.Workbooks.Open(fichierCible);
foreach (NetOffice.ExcelApi.Worksheet sheet in book.Worksheets)
Range xlActiveRange = sheet.UsedRange;
object[,] objRangeSheet = xlActiveRange.Value as object[,];
for (int numeroColonne = 1; numeroColonne <= objRangeSheet.GetLength(1); numeroColonne++)
for (int numeroLigne = 1; numeroLigne <= objRangeSheet.GetLength(0); numeroLigne++)
if (sheet.Cells[numeroLigne, numeroColonne].Value != null)
if (listErrorExcel.ContainsKey(sheet.Cells[numeroLigne, numeroColonne].Value.ToString()))
Console.WriteLine("Une erreur est survenue lors du traitement de la ligne " + (numeroLigne) + " et de la colonne : " + (numeroColonne));
Console.WriteLine(sheet.Cells[numeroLigne, numeroColonne].Value.ToString());