title: ExcelDataReader Error on Web Server - Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
body: <p>I am attempting to write results of records being updated to an Excel file using ExcelDataReader after each successful update.  Currently, the functionality works fine on my machine running thru Visual Studio, however, once this same functionality is executed from our web server, the following error occurs:</p>
  
  <blockquote>
    <p>Error: Retrieving the COM class factory for component with CLSID
    {00024500-0000-0000-C000-000000000046} failed due to the following
    error: 80040154 Class not registered (Exception from HRESULT:
    0x80040154 (REGDB_E_CLASSNOTREG)).</p>
  </blockquote>
  
  <p>I am not sure, at this point, how to solve this error at this point.  PLEASE HELP.</p>
  
  <p>My codebehind for the executing code is as follows:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using BL.WebUserProvider;
  using VO.WebUserProvider;
  using System.Data;
  using Excel;
  
      private void ExportDataSetToExcel(DataSet ds)
          {
  
              // Export Data into EXCEL Sheet
              ApplicationClass ExcelApp = new ApplicationClass();
              ExcelApp.Application.Workbooks.Add(Type.Missing);
  
              // Write data into excel sheet cells
              for (int i = 1; i &lt; ds.Tables[0].Rows.Count + 2; i++) // Row Count accounts for "Column" row and itteration starting at index 1 (Confusing...I know)
              {
                  for (int j = 1; j &lt; ds.Tables[0].Columns.Count + 1; j++)
                  {
                      if (i == 1)
                          ExcelApp.Cells[i, j] = ds.Tables[0].Columns[j - 1].ToString();
                      else
                          ExcelApp.Cells[i, j] = ds.Tables[0].Rows[i - 2][j - 1].ToString();
                  }
              }
  
              // save excel file 
              ExcelApp.ActiveWorkbook.SaveCopyAs(string.Format("{0}-{1}-{2}  {3}.{4}.{5} - {6} records.xlsx",
                  DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, ds.Tables[0].Rows.Count));
  
              ExcelApp.ActiveWorkbook.Saved = true;
              ExcelApp.Quit();
          }
  </code></pre>