Read Excel Files Using Open XML SDK In ASP.NET C#


A few days back, I got a requirement to read MS Excel files and store those values in the SQL Server database. Hence, in this example, I am going to show how to get the basic four types of important data such as Excel Work Book Name, Worksheet Count in that Workbook, Name of the Worksheets, and finally the Value of the First Cell in that Worksheet.


First step is to download the Openxml dll from the official site.

Second step is to kindly ensure to add the above dll, as shown in the screenshot, given below:



Important note

Once you load this dll and write the code, you will get the following error:


Resolution for above problem is,


Add the above dll also to the project.


  1. using DocumentFormat.OpenXml.Packaging;
  2. using DocumentFormat.OpenXml.Spreadsheet;

C# Code



If the cell contains a string, then this value is an index into the shared string table, pointing to the actual string value. Otherwise, the value of the cell is expressed directly in this element

Source: CellValue Class

For taking the string Value from Cell



Other References

Link to: Read excel files using Microsoft Office Interop Assemblies in

I hope the above information was useful. Kindly let me know your thoughts.

951 total views, 2 views today

Leave a Reply

Your email address will not be published. Required fields are marked *