Re: How to open an excel file
Steve Abaffy <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <001501c76a5c$1d58e8d0$580aba70$@biz> |
Ok that got me past that problem but I have new one. Here is the code:
private Microsoft.Office.Interop.Excel._Application ExcelObj;
private Microsoft.Office.Interop.Excel._Workbook Workbook;
private Microsoft.Office.Interop.Excel._Worksheet Sheets;
private Microsoft.Office.Interop.Excel.Range Range;
private string filename;
public string FileName { get { return filename; } set { filename = value; }
}
public string[] GetListValues()
{
ExcelObj = new Microsoft.Office.Interop.Excel.ApplicationClass();
Workbook = ExcelObj.Workbooks.Open(filename, 0, false, 5, "", "", true,
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, ",", true, false, 0,
true, true, false);
Sheets = (Microsoft.Office.Interop.Excel._Worksheet)Workbook.Sheets; //Error
Here
Range = Sheets.get_Range("A1", "AZ1");
}
This complies but errors out at the point shown
What am I doing wrong, this really shouldn't this hard.
-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps and
controls [mailto:[email protected]] On Behalf Of Patrick
Steele
Sent: Monday, March 19, 2007 1:56 PM
To: [email protected]
Subject: Re: [DOTNET-WINFORMS] How to open an excel file
Usually on those interop assemblies, the "leading underscore" name
represents the default COM interface. That actuall class to instantiate
is the name with "Class" appended on to it:
_Application app = new ApplicationClass();
--
Patrick Steele
http://weblogs.asp.net/psteele
-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps
and controls [mailto:[email protected]] On Behalf Of
Steve Abaffy
Sent: Monday, March 19, 2007 2:48 PM
To: [email protected]
Subject: [DOTNET-WINFORMS] How to open an excel file
Hello,
I have Microsoft.Office.Interop.Excel add as a Reference as well
as
Microsoft.Office.Core and I have the following line of code:
private Microsoft.Office.Interop.Excel._Application ExcelObj;
ExcelObj = new Microsoft.Office.Interop.Excel._Application();
And I get the error
Cannot create an instance of the abstract class or interface
Microsoft.Office.Interop.Excel._Application
What am I doing wrong???