gmoconno
asked on
The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)
Hi,
I am using Microsoft Visual Studio.NET 2003. I am trying to do somw work with EXCEL and keep getting the following error.
The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)
I have added the following to the project:
Microsoft Excel 11.0 Object Library
Microsoft Office 11.0 Object Library
Microsoft XP PIA's
the following is my code but it doesn't seem to recognise using Excel;
Wwould appreciate any help.
using System;
using Excel;
using System.Collections;
namespace exer
{
class ExcelClass
{
/// <summary>
/// The main entry point for the application.
/// </summary>
private string Cfilename;
public Excel.Application excelApp ; // Creates a new Excel Application
public Excel.Workbook excelWorkbook;
public Excel.Sheets excelSheets;
public Excel.Worksheet excelWorksheet;
public void Start(string filename)
{
Cfilename=filename;
excelApp = new Excel.ApplicationClass();
excelWorkbook = excelApp.Workbooks.Open(fi lename, 0,
false, 5, "", "", false, Excel.XlPlatform.xlWindows , "", true,
false, 0, true, false, false);
}
public void openSheet(string currentSheet) // The following gets the Worksheets collection
{
excelSheets = excelWorkbook.Worksheets;
excelWorksheet = (Excel.Worksheet)excelShee ts.get_Ite m(currentS heet);
}
public void setcell(string val)
{
// The following gets cell A1 for editing
excelSheets = excelWorkbook.Worksheets;
Excel.Range excelCell = (Excel.Range)excelWorkshee t.get_Rang e("A1", "A1");
// The following sets cell A1's value to "Hi There"
excelCell.Value2 = val;
}
public void view()
{
excelApp.Visible=true;// Makes Excel visible to the user.
}
public void Close()
{
excelWorkbook.Close(false, Cfilename, false);
excelApp.Quit();
excelApp=null;
}
}
I am using Microsoft Visual Studio.NET 2003. I am trying to do somw work with EXCEL and keep getting the following error.
The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)
I have added the following to the project:
Microsoft Excel 11.0 Object Library
Microsoft Office 11.0 Object Library
Microsoft XP PIA's
the following is my code but it doesn't seem to recognise using Excel;
Wwould appreciate any help.
using System;
using Excel;
using System.Collections;
namespace exer
{
class ExcelClass
{
/// <summary>
/// The main entry point for the application.
/// </summary>
private string Cfilename;
public Excel.Application excelApp ; // Creates a new Excel Application
public Excel.Workbook excelWorkbook;
public Excel.Sheets excelSheets;
public Excel.Worksheet excelWorksheet;
public void Start(string filename)
{
Cfilename=filename;
excelApp = new Excel.ApplicationClass();
excelWorkbook = excelApp.Workbooks.Open(fi
false, 5, "", "", false, Excel.XlPlatform.xlWindows
false, 0, true, false, false);
}
public void openSheet(string currentSheet) // The following gets the Worksheets collection
{
excelSheets = excelWorkbook.Worksheets;
excelWorksheet = (Excel.Worksheet)excelShee
}
public void setcell(string val)
{
// The following gets cell A1 for editing
excelSheets = excelWorkbook.Worksheets;
Excel.Range excelCell = (Excel.Range)excelWorkshee
// The following sets cell A1's value to "Hi There"
excelCell.Value2 = val;
}
public void view()
{
excelApp.Visible=true;// Makes Excel visible to the user.
}
public void Close()
{
excelWorkbook.Close(false,
excelApp.Quit();
excelApp=null;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER