excel in C# 
Author Message
 excel in C#

Hi, there,

If I want to create an object which will open excel in c sharp, what class
and method I should use?

Thanks a lot.

-May



Thu, 30 Dec 2004 07:21:23 GMT  
 excel in C#

Quote:

> Hi, there,

Nihau.

Quote:
> If I want to create an object which will open excel in c sharp, what class
> and method I should use?

First, you have to create a managed assembly "wrapper" for Excel,
if you haven't already.  You do this with the TLBIMP command-line
utility.  Locate the Excel type library (either excel.olb or in XP it's
inside excel.exe itself)  Run TLBIMP on it.  When you build your
C# code, add a reference to the Excel.dll generated by TLBIMP.

Create a new Excel.Application, then set the Visible property to true.

- - -
    using Excel;
    // ...
    Application excel = new Application( );
    excel.Visible = true;
- - -

There is a Sample included with the .NET Framework SDK that
demonstrates automating Excel. See the documentation for:

.NET Framework SDK /
Samples /
Technology Samples /
Interop /
Applications /
Microsoft Office Technology Sample

Note that if you installed the Framework SDK with VS.NET,
the Samples folder may be located underneath your
/Program Files/Visual Studio .Net folder.

Quote:
> Thanks a lot.

Bukechi,

Derek Harmon



Thu, 30 Dec 2004 06:51:42 GMT  
 excel in C#
It's even a little easier than that if you have Visual Studio.  Simply "Add
Reference", go to the COM tab, select the Excel library, and voila, you're
done.

Note that the interop lib produced for Excel by tblimp (or Visual Studio)
will not properly let you handle events;  you'll need to modify the interop
lib by disassembling, editing by hand, and reassembling.

If you're not using Excel events, don't worry about it, it works fine.

--
-Greg Pasquariello



Quote:
> > Hi, there,

> Nihau.

> > If I want to create an object which will open excel in c sharp, what
class
> > and method I should use?

> First, you have to create a managed assembly "wrapper" for Excel,
> if you haven't already.  You do this with the TLBIMP command-line
> utility.  Locate the Excel type library (either excel.olb or in XP it's
> inside excel.exe itself)  Run TLBIMP on it.  When you build your
> C# code, add a reference to the Excel.dll generated by TLBIMP.

> Create a new Excel.Application, then set the Visible property to true.

> - - -
>     using Excel;
>     // ...
>     Application excel = new Application( );
>     excel.Visible = true;
> - - -

> There is a Sample included with the .NET Framework SDK that
> demonstrates automating Excel. See the documentation for:

> .NET Framework SDK /
> Samples /
> Technology Samples /
> Interop /
> Applications /
> Microsoft Office Technology Sample

> Note that if you installed the Framework SDK with VS.NET,
> the Samples folder may be located underneath your
> /Program Files/Visual Studio .Net folder.

> > Thanks a lot.

> Bukechi,

> Derek Harmon



Thu, 30 Dec 2004 10:43:46 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. self-deleting object (managing Excel from C#)

2. Programmitcally Creating Controls in Excel from C#

3. Creating reports in Excel from C#

4. Calling Excel from C#

5. IDataObject is null copying Clipboard from Excel in C#

6. Controlling Excel from C#

7. How to delete a picture in Excel using C#

8. Closing Excel from C#

9. Controlling Excel from C#

10. Excel and C#

11. Excel and C#

12. Instance of Excel in C# Windows Form

 

 
Powered by phpBB® Forum Software