Background
A few days ago I got a requirement to read Excel files and store those values in the Sql server database. So in this example am going to show how to get the basic four import datas such as Excel Work Book Name, Worksheet Count in that Workbook, Name of the First Worksheet, and finally the value of the first cell in that worksheet.
Prerequisites
Kindly ensure you add the following dll as shown in the below screenshot,


Namespace
using Excel = Microsoft.Office.Interop.Excel;
C# Code
- protected void BtnGetExcelFileDetails_Click(object sender, EventArgs e)
- {
- try
- {
- //create a instance for the Excel object
- Excel.Application oExcel = new Excel.Application();
- //specify the file name where its actually exist
- string filepath = @ "D:\TPMS\Uploaded_Boq\Raveena_boq_From_Db.xlsx";
- //pass that to workbook object
- Excel.Workbook WB = oExcel.Workbooks.Open(filepath);
- // statement get the workbookname
- string ExcelWorkbookname = WB.Name;
- // statement get the worksheet count
- int worksheetcount = WB.Worksheets.Count;
- Excel.Worksheet wks = (Excel.Worksheet) WB.Worksheets[1];
- // statement get the firstworksheetname
- string firstworksheetname = wks.Name;
- //statement get the first cell value
- var firstcellvalue = ((Excel.Range) wks.Cells[1, 1]).Value;
- } catch (Exception ex)
- {
- string error = ex.Message;
- }
- }

Karthik ElumalaiPosted Mar 22, 2018, 12:52 PM
HI to read .xlsb file, i hope this link:https://forums.asp.net/t/2125945.aspx?Read+the+content+of+Excel+Binary+File+XLSB+file+using+EPPlus+library+or+any+other+dll will give you the better guidance thanks.
ajay kumarPosted Mar 22, 2018, 1:29 AM
How to read .xlsb file With out ms office