locked
Microsoft.Office.Interop.Excel.dll RRS feed

  • Question

  • Hi again

    I am still having problems with this Excel Interop ...

    I did a little sample application.
    It just opens a excel file and than closes it.
    I refer directly to Microsoft.Office.Interop.Excel.dll
    Platform Target is set to x86 (I tried also x64).
    When I run it on a x86 Windows XP Machine it works fine.

    When I run it on a x64 Windows 2003 Server the following error comes:
    Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.

    This exeption comes up at this line:
    Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();

    The code looks like:
    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");

    Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
    Microsoft.Office.Interop.Excel.Workbook ObjWorkBook;
    Microsoft.Office.Interop.Excel.Worksheet ObjWorkSheet;
    ObjExcel.DisplayAlerts = false;
    ObjExcel.Visible = false;

    ObjWorkBook = ObjExcel.Workbooks.Open(@"C:\Temp\Temp.xls", false, true,
                                                      Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                      Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                      Type.Missing, Type.Missing, Type.Missing, Type.Missing);

    ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)ObjWorkBook.Sheets[1];

    ObjWorkSheet = null;
    ObjWorkBook.Close(Microsoft.Office.Interop.Excel.XlSaveAction.xlDoNotSaveChanges, Type.Missing, Type.Missing);
    ObjExcel = null;


    Any ideas?? I am happy for any comments !!
    Best regards
    Frank Uray
    Wednesday, September 6, 2006 9:33 AM

Answers

  • I Know that this work:

    using System;

    using Microsoft.Office.Interop.Excel;

    namespace TesteExcel_1

    {

    /// <summary>

    /// Summary description for Class1.

    /// </summary>

    class Class1

    {

    /// <summary>

    /// The main entry point for the application.

    /// </summary>

    [STAThread]

    static void Main(string[] args)

    {

    Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();

    Microsoft.Office.Interop.Excel.Workbook ObjWorkBook;

    Microsoft.Office.Interop.Excel.Worksheet ObjWorkSheet;

    ObjWorkBook = ObjExcel.Workbooks.Open(@"c:\\CarteiraV3.xls", 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);

    ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet) ObjWorkBook.Sheets[1];

    ObjWorkSheet.Name = "NomeDaTabela";

    ObjWorkBook.Save();

    ObjWorkBook.Close(Microsoft.Office.Interop.Excel.XlSaveAction.xlSaveChanges, Type.Missing,Type.Missing);

    ObjExcel.Quit();

    int a =0;

    }

    }

    }

    //sorry for code organize.....isn't my fault!

     

     

    Thursday, October 19, 2006 11:38 AM

All replies

  • I Know that this work:

    using System;

    using Microsoft.Office.Interop.Excel;

    namespace TesteExcel_1

    {

    /// <summary>

    /// Summary description for Class1.

    /// </summary>

    class Class1

    {

    /// <summary>

    /// The main entry point for the application.

    /// </summary>

    [STAThread]

    static void Main(string[] args)

    {

    Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();

    Microsoft.Office.Interop.Excel.Workbook ObjWorkBook;

    Microsoft.Office.Interop.Excel.Worksheet ObjWorkSheet;

    ObjWorkBook = ObjExcel.Workbooks.Open(@"c:\\CarteiraV3.xls", 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);

    ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet) ObjWorkBook.Sheets[1];

    ObjWorkSheet.Name = "NomeDaTabela";

    ObjWorkBook.Save();

    ObjWorkBook.Close(Microsoft.Office.Interop.Excel.XlSaveAction.xlSaveChanges, Type.Missing,Type.Missing);

    ObjExcel.Quit();

    int a =0;

    }

    }

    }

    //sorry for code organize.....isn't my fault!

     

     

    Thursday, October 19, 2006 11:38 AM
  • Good day...
    I was just wondering is it possible to read from a xls sheet if the computer does not have excel installed on it? The development machine does have excel but then i need to deploy it to a machine that does not have excel yet it needs to read from the file and write it into a DB?
    Coffee is what makes civilised life Possible
    Thursday, June 4, 2009 2:05 PM
  • With OleDB provider is posible to make querys like Sql over an excel file without need of install. Also you can make updates but not works fine.
    Desarrollador de software
    Thursday, June 11, 2009 8:34 AM
  • little bit late for this reply but thank you i eventually went over to writing a web application. This way i can have only one Microsoft license on the server yet everyone can work on it.

    Coffee is what makes civilised life Possible
    Friday, July 31, 2009 7:12 AM