Tutorial by Examples

//create a list to hold all the values List<string> excelData = new List<string>(); //read the Excel file as byte array byte[] bin = File.ReadAllBytes("C:\\ExcelDemo.xlsx"); //or if you use asp.net, get the relative path byte[] bin = File.ReadAllBytes(Server.MapPath(&q...
//set the formatting options ExcelTextFormat format = new ExcelTextFormat(); format.Delimiter = ';'; format.Culture = new CultureInfo(Thread.CurrentThread.CurrentCulture.ToString()); format.Culture.DateTimeFormat.ShortDatePattern = "dd-mm-yyyy"; format.Encoding = new UTF8Encoding(); ...
//check if there is actually a file being uploaded if (FileUpload1.HasFile) { //load the uploaded file into the memorystream using (MemoryStream stream = new MemoryStream(FileUpload1.FileBytes)) using (ExcelPackage excelPackage = new ExcelPackage(stream)) { //loop all ...
public static DataTable ExcelPackageToDataTable(ExcelPackage excelPackage) { DataTable dt = new DataTable(); ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets[1]; //check if the worksheet is completely empty if (worksheet.Dimension == null) { return dt;...

Page 1 of 1