PDA

Click to See Complete Forum and Search --> : Populating Excel


Dorothy
Sep 12th, 2002, 10:44 PM
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?

MasterBlaster
Sep 13th, 2002, 12:04 PM
:eek:

Dorothy
Sep 15th, 2002, 11:16 PM
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";

Dorothy
Sep 17th, 2002, 12:55 AM
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?