Reading Excel file data from an HttpPostedFileBase object

The downloaded Excel file is in the HttpPostedFileBase object

HttpPostedFileBase hpf = Request.Files ["ExcelFileeUploader"];

Want to read Excel data from this object. thanks.

+4
source share
1 answer

If you are using EPPlus , it is that simple:

public void ImportExcelXls(HttpPostedFileBase fileBase) { using (var package = new ExcelPackage(fileBase.InputStream)) { // get the first worksheet in the workbook ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; int col = 1; for (int row = 1; worksheet.Cells[row, col].Value != null; row++) { // do something with worksheet.Cells[row, col].Value } } // the using } 
+8
source

All Articles