Comment ouvrir et lire un fichier Excel en C# ?
Méthode recommandée (EPPlus) :
using OfficeOpenXml;
using (var package = new ExcelPackage(new FileInfo("fichier.xlsx")))
{
var ws = package.Workbook.Worksheets[0];
string val = ws.Cells[1, 1].Value?.ToString();
}
Avec Interop (nécessite Excel installé) :
var excelApp = new Microsoft.Office.Interop.Excel.Application();
var workbook = excelApp.Workbooks.Open(@"C:\fichier.xlsx");