Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhishek YadavRank #217 · 11.3K reputationPosted Nov 1, 2022, 12:07 AM EDT
string filename = FileUpload1.FileName; string extension = Path.GetExtension(FileUpload1.PostedFile.FileName); String PATH = Server.MapPath("~/NewFolder1/") + filename; FileUpload1.SaveAs(PATH); FileStream stream = File.Open(PATH, FileMode.Open, FileAccess.Read); string filename_tmp = ""; // 9aug21 IExcelDataReader excelReader = null; switch (extension) { case ".xls": //1. Reading from a binary Excel file ('97-2003 format; *.xls) excelReader = ExcelReaderFactory.CreateBinaryReader(stream); filename_tmp = filename.Replace(".xls", ""); // 9aug21 break; case ".xlsx": //2. Reading from a OpenXml Excel file (2007 format; *.xlsx) excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); filename_tmp = filename.Replace(".xlsx", ""); // 9aug21 break; } excelReader.IsFirstRowAsColumnNames = true; DataTable dt = new DataTable(); DataSet result = excelReader.AsDataSet(); dt = result.Tables[0];use iexcel as it is easy to use and free
Leon DRank #851 · 2.6K reputationPosted Oct 31, 2022, 9:26 PM EDT
Free Spire.XLS for .NET (https://www.e-iceblue.com/Introduce/free-xls-component.html) is capable of creating, reading and editing excel files in asp.net core, and it is free for both personal and commercial use.
You can find its detailed functionalities by visiting the documentation below:
https://www.e-iceblue.com/Tutorials/Spire.XLS/Spire.XLS-Program-Guide/Spire.XLS-Program-Guide-Content.html
Vishal YelveRank #178 · 13.6K reputationPosted Nov 2, 2022, 3:42 AM EDT
Hi Naresh,
Use Open XML
To read data from excel
https://www.c-sharpcorner.com/article/how-to-read-data-from-an-excel-sheet/
To add and update
https://www.c-sharpcorner.com/blogs/add-update-rows-data-in-excel-using-open-xml-and-c-sharp