I'm developing an ASP.NET MVC C# Application to take data from excel file and extract info from it to replace an Email Template that user created. But I see in many results I search the method so complicated and long. I would like to know the most simply want to take data from excel file. For example, my mail template has a placeholder and I would like to extract the data from Distributor column and create a list of mail based on the excel file, how many rows does it have.
-
2Possible duplicate of Reading Excel files from C#Svetoslav Petrov– Svetoslav Petrov2018-06-27 09:40:32 +00:00Commented Jun 27, 2018 at 9:40
-
Look up how to use Microsoft.Office.Interop.Excel.dllWheels73– Wheels732018-06-27 10:42:18 +00:00Commented Jun 27, 2018 at 10:42
-
1Look at the OpenXML SDK for Excel 2007+ to read the raw file without Excel.Mark Fitzpatrick– Mark Fitzpatrick2018-06-27 11:47:07 +00:00Commented Jun 27, 2018 at 11:47
Add a comment
|
1 Answer
Do not use interop in Server environment:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment. Source: Microsoft note.
Check out this library - ExcelDataReader. It is fast and reliable and definitely not requires much code.