For greater clarity, I want to add a clear example and running
openFileDialog1.FileName = "Select File";
openFileDialog1.DefaultExt = ".xls";
openFileDialog1.Filter = "Excel documents (.xls)|*.xls";
DialogResult result = openFileDialog1.ShowDialog();
if (result==DialogResult.OK)
{
string filename = openFileDialog1.FileName;
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.Application();
xlApp.Visible = false;
xlApp.DisplayAlerts = false;
xlWorkBook = xlApp.Workbooks.Open(filename, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
var numRows = xlWorkSheet.Range["A1"].Offset[xlWorkSheet.Rows.Count - 1, 0].End[Excel.XlDirection.xlUp].Row;
MessageBox.Show("Number of max row is : "+ numRows.ToString());
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
}