Julian Gonzalez

Generation

generate functionFri, 31 Mar 2023

Read excel file in .NEt 6 using EPPlus library

public static void ReadExcel(string filePath) { FileInfo file = new FileInfo(filePath); using (ExcelPackage package = new ExcelPackage(file)) { ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; var rowCount = worksheet.Dimension.Rows; for (int row = 1; row <= rowCount; row++) { var name = worksheet.Cells[row, 1].Value; var age = worksheet.Cells[row, 2].Value; Console.WriteLine( $"Name: {name} - Age: {age}"); } } }

Questions about programming?Chat with your personal AI assistant