Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Performance / July 2007

Tip: Looking for answers? Try searching our database.

Running Excel in a console app

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alexander Kolev - 10 Jul 2007 09:40 GMT
Hi,

I've implemented a simple console application that runs Excel, attaches a
macro and then saves the excel file with applied macro file.

This is implemented in a single method.

It takes me 30 seconds to run the console application with a small xsl file
(20 KB) and very simple marco.

I added trace before calling the method and in the first line inside the
method. Then I saw that this delta is 30 seconds.

-----------------------------------------------------------------
void Main()
{
Trace.WriteLine( "Before Run marco");

RunMacro();
}

void RunMacro()
{
Trace.WriteLine( "In Run marco");

// code to run that construct Excel and runs the macro file
}

It seems that it takes a lot of time to CLR to build/create/compile the
Runtime Callable warpper or something like that?

Any help is appreciated.

Thanks in advance.

Run
Alvin Bruney [MVP] - 11 Jul 2007 02:50 GMT
I think the time spent is actually in automating excel; ie getting it to
start. When you run the application, go to task manager and see if there is
an excel.exe running. If there is, that's probably the reason. There are
ways to do it without starting word which includes basically parsing the
file.

Signature

Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
https://www.microsoft.com/MSPress/books/10933.aspx
OWC Black Book www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley

> Hi,
>
[quoted text clipped - 33 lines]
>
> Run
Alexander Kolev - 11 Jul 2007 11:30 GMT
But I have counted the time of 30 seconds before calling

xl = new Microsoft.Office.Interop.Excel.ApplicationClass();

That means Excel.exe is still not running.

I am wondering whether for the time of 30 seconds the CLR is JIT compiling
RCW for the Excel automation class or is doing something else, and how can I
redure this time

There are
> ways to do it without starting word which includes basically parsing the
> file. => Not clear !!!

> I think the time spent is actually in automating excel; ie getting it to
> start. When you run the application, go to task manager and see if there is
[quoted text clipped - 39 lines]
> >
> > Run
Bram - 17 Jul 2007 12:59 GMT
Hi Alexander,

The .NET runtime uses a Just In Time (JIT) compiler. Basically this
means that all assemblies will be loaded on the fly whenever they are
first actually used. In your case, .NET detects that you're about to
use Microsoft.Office.Interop.Excel, so it loads the Assembly. Even if
it's not actually *starting* excel, it's not inconceivable that a
large part of the runtimes used by Excel also need to be loaded, which
can take quite some time.

Are you performing the action in a batch process? In that case, it
might be a good idea to hoist some of the batch logic into your .NET
application in such a way that instead of:

MyExcelMacroAttacher.exe c:\Excel\Sheet1.xls
MyExcelMacroAttacher.exe c:\Excel\Sheet2.xls
MyExcelMacroAttacher.exe c:\Excel\Sheet3.xls
MyExcelMacroAttacher.exe c:\Excel\Sheet4.xls

you can run:

MyExcelMacroAttacher.exe c:\Excel\

You'll still have to load the runtimes (there's no changing that, if
you want to use Excel Interop), but you'll only have to do it once.

Hope it helps!

Regards
Bram

On Jul 11, 12:30 pm, Alexander Kolev
<AlexanderKo...@discussions.microsoft.com> wrote:
> But I have counted the time of 30 seconds before calling
>
[quoted text clipped - 63 lines]
>
> > > Run

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.