Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' : <p>This is not duplicate read full question</p>

<p>I have console application.</p>

<p>here I want to export data set value to excel </p>

<p>for that i going to use this
i have used microsoft.office.interop.excel.dll</p>

<p>and and using this namespace</p>

<p>using Excel = Microsoft.Office.Interop.Excel;</p>

<p>this is  my excel export code</p>

<pre><code> private static bool ExportDataTableToExcel(DataTable dt, string filepath)
    {

        Excel.Application oXL;
        Excel.Workbook oWB;
        Excel.Worksheet oSheet;
        Excel.Range oRange;

        try
        {      
            oXL = new Excel.Application();
            oXL.Visible = true;
            oXL.DisplayAlerts = false;

            oWB = oXL.Workbooks.Add(Missing.Value);

            oSheet = (Excel.Worksheet)oWB.ActiveSheet;
            oSheet.Name = "Data";

            int rowCount = 1;
            foreach (DataRow dr in dt.Rows)
            {
                rowCount += 1;
                for (int i = 1; i &lt; dt.Columns.Count + 1; i++)
                {
                    // Add the header the first time through 
                    if (rowCount == 2)
                    {
                        oSheet.Cells[1, i] = dt.Columns[i - 1].ColumnName;
                    }
                    oSheet.Cells[rowCount, i] = dr[i - 1].ToString();
                }
            }


            oRange = oSheet.get_Range(oSheet.Cells[1, 1],
                          oSheet.Cells[rowCount, dt.Columns.Count]);
            oRange.EntireColumn.AutoFit();

            oSheet = null;
            oRange = null;
            oWB.SaveAs(filepath, Excel.XlFileFormat.xlWorkbookNormal,
                Missing.Value, Missing.Value, Missing.Value, Missing.Value,
                Excel.XlSaveAsAccessMode.xlExclusive,
                Missing.Value, Missing.Value, Missing.Value,
                Missing.Value, Missing.Value);
            oWB.Close(Missing.Value, Missing.Value, Missing.Value);
            oWB = null;
            oXL.Quit();
        }
        catch
        {
            throw;
        }
        finally
        {

            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
        }

        return true;
    }
</code></pre>

<p>when I run my code i am getting error</p>

<p>Could not load file or assembly 'office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.</p>

<p>i am not installed ms office in my pc.</p>

<p>I thought I not installed MSOffice in my pc so that only i am getting error.</p>

<p>if this is not error I made error in my code can anyone tell me</p>
