Results 1 to 4 of 4

Thread: Populating Excel

  1. #1

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310

    Question Populating Excel

    Iam trying to populate an Excel sheet using the COM MS Excel Lib10.0 using the following code:

    Excel.Application a = new Excel.Application();
    Excel.Workbook wb = a.Open ("C:\book1.xls");
    Excel.Worksheet ws = wb.Worksheets.Item (1);

    ws. Cells [2, 1].value = "YOUR STRING VALUE";
    ws. Cells[ 2, 2].value = "YOUR STRING VALUE";


    I get errors in the underlined lines. Help me out?

  2. #2
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196
    Last edited by MasterBlaster; Nov 21st, 2002 at 03:42 PM.

  3. #3

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310
    On Pressing F5

    There were builder errors, continue?
    The following or the errors for the underlined lines >>
    1. For a.open: Excel.Application does not contain a definition for open.
    2. For Item: Provider Indexer or event item not supported by the language.
    3. For Cells: Object does not contain a definition for values.

    When I modified the last lines, I dont get the last error(3)

    ws.Cells[2, 1] = "YOUR STRING VALUE";
    ws.Cells[2, 2] = "YOUR STRING VALUE";

  4. #4

    Thread Starter
    Hyperactive Member Dorothy's Avatar
    Join Date
    Feb 2001
    Posts
    310

    Angry

    This is the recent code:

    Excel.Application a=new Excel.ApplicationClass();
    Excel.Worksheet ws=new Excel.WorksheetClass();
    Excel.WorkbookClass wb;
    Excel.Application a=new Excel.ApplicationClass();
    wb = (Excel.WorkbookClass)a.Workbooks._Open("C:\\book1.xls",true,true,"mm","","",true,true,".",true,false ,true,true);
    ws = (Excel.Worksheet)wb.Worksheets[1];
    ws.Cells[2, 1] = "Date";
    ws.Cells[2, 2] = "Location";]


    I have a run-time error only in the underlined line:

    An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in vcexcel1.exe

    Additional information: COM object with CLSID {00020819-0000-0000-C000-000000000046} is either not valid or not registered.


    Any help?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width