Here Mudassar Ahmed Khan has explained with an example, how to used ClosedXML library in ASP.Net MVC Razor.
This article will also explain how to use ClosedXML library to export DataTable (DataSet) to Excel file in ASP.Net MVC Razor.
The data from the database is fetched using Entity Framework and then it is used to populate a DataTable.
Then the DataTable is exported and downloaded as Microsoft Excel file using ClosedXML Excel Library which is a wrapper for OpenXml Excel library.