Use Microsoft.Office.Interop.Excel your may as like below... it may help you
public void ImportXLX()
{
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook wb = app.Workbooks.Open(@"C:\Users\Vipin\Desktop\Sheets\MyXL6.xlsx", Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
int workSheetCounts = wb.Worksheets.Count;
for (int sheetCounter = 1; sheetCounter <= workSheetCounts; sheetCounter++)
{
Microsoft.Office.Interop.Excel.Worksheet workSheet = wb.Sheets[sheetCounter];
Range excelRange = workSheet.UsedRange;
Range objRange = null;
int rowCountForHeight = 0;
double totalColHeight = 0;
double totalRowWidth = 0;
foreach (Microsoft.Office.Interop.Excel.Range row in excelRange.Rows)
{
rowCountForHeight++;
int colCount = 0;
foreach (Microsoft.Office.Interop.Excel.Range c in row.Cells)
{
colCount++;
objRange = workSheet.Cells[rowCountForHeight, colCount];
double height = 0;
if (objRange.MergeCells)
{
Debug.Write("CellsMerged \n");
height = ((Range)objRange.MergeArea[1, 1]).Height;
}
else
{
Debug.Write("CellsMergedNot \n");
height = objRange.Height;
}
totalColHeight = totalColHeight + height;
}
}
int rowCount = 0;
foreach (Microsoft.Office.Interop.Excel.Range row in excelRange.Rows)
{
rowCount++;
totalRowWidth = row.Width;
int colCount = 0;
foreach (Microsoft.Office.Interop.Excel.Range c in row.Cells)
{
colCount++;
objRange = workSheet.Cells[rowCount, colCount];
double width = 0;
double height = 0;
string colVal = null;
if (objRange.MergeCells)
{
colVal = Convert.ToString(((Range)objRange.MergeArea[1, 1]).Text).Trim();
width = objRange.MergeArea.Width;
height = objRange.MergeArea.Height;
}
else
{
colVal = Convert.ToString(objRange.Text).Trim();
width = objRange.Width;
height = objRange.Height;
}
Debug.Write("objRange = " + objRange + " rowCount = " + rowCount + " Width = " + width + " height = " + height + "TotalColumnWidth = " + totalRowWidth + "TotalRowHeight = " + totalColHeight + " \n ");
}
}
}
app.Quit();
}