RE: Excel Calculation is faster when visible than when Visible=Fal
- From: JeffDotNet <JeffDotNet@xxxxxxxxxxxxxxxxx>
- Date: Thu, 27 Mar 2008 16:41:00 -0700
Jialiang thanks for your suggestions. Unfortunately, I still haven’t solved
the problem.
Setting the calculation mode back to automatic is the CPU hog. I set
dataSheet.EnableCalculation = False but this didn't appear to have an impact
on speed. The import of the text file to the data page is relatively quick (
less than a second)
Public Sub importDataFromFile(ByVal FilePath As String)
Me.CalculationMode = Excel.XlCalculation.xlCalculationManual
'Import CSV file into data worksheet
importDataFromFile(FilePath, Sheets.Data)
Me.CalculationMode = Excel.XlCalculation.xlCalculationAutomatic
'(objApp.Calculation = Excel.XlCalculation.xlCalculationAutomatic)
m_Calculating = False
End Sub
The chart below show execution times for setting the spreadsheet back to
automatic calculation after the csv data import.
Run Column: Shows the consecutive runs. Here I'm reusing the same excel
instance, but loading new csv files. Note this execution time get
significantly faster each run even in manually importing the csv files into
the spread sheet.
Manual: This shows the same data import (edit text import) and calculation
done in excel without interop
Visible: Execution time when running with Excel instance visible
NotVisible: Execution time when running with Excel not visible
-------------Execution time in Seconds--------------
Run # Manual Visible NotVisible
1 50 59.7 301.4
2 9 47.3 67.8
3 ~0.5 0.37 0.3
4 ~0.5 0.28 0.3
----------------------------------------------------
I also noticed that when running with the excel instance visible but
minimized yielded the same
results as running with the instance set to not visible.
I tried calculating the pages individually but didn't see a real performance
improvement. Nearly all of the time is spent calculating one of the analysis
Worksheets. I noticed this worksheet uses Dmax, Dmin, and Daverage. Could
the searching in these functions cause strange execution times? (it gets
faster each time when using the spreadsheet manually )
Is there anyway clever way to get this waiting out of the way in advance?
My users will rarely be running more than one analysis a day. Therefore
they will always experience
a long wait. I really don't want to have to run with excel visible. I
think I should be able to get the cell calculation to execute invisibly at
least as fast as when the instance is executing visible.
Thanks,
Jeff
"Jialiang Ge [MSFT]" wrote:
Hello Jeff,.
There seems something wrong with newsgroup post synchronization in this
thread. I am sorry for it. Below is my initial response posted on March 25.
Hello Jeff,
From your post, my understanding on this issue is: you wonder why the
ImportDataFromFile process is extremely slow only when
Excel.Application.Visible = false, and how to resolve it. If I'm off base,
please feel free to let me know.
First off, I suggest we identify which part of code in ImportDataFromFile
slows down the whole process when Application.Visible=false. Below are the
two possible approaches that can help us identify the location:
Approach 1. Debug the code lines. Step over each line of code in
ImportDataFromFile, and see which line hangs for a extremely long time. If
you are using Visual Studio, we can step over the code lines by pressing
F10.
Approach 2. Use a stop watch class to calculate each line's execution time:
http://www.codeproject.com/KB/vb/vbnetstopwatch.aspx. An
easier-to-implement stop watch is like:
Dim start As DateTime = DateTime.Now
'execute our code
Dim [end] As DateTime = DateTime.Now
Dim span As TimeSpan = [end] - start
I think knowing which part of code slows down the process may help us
determine the underlying reason for the performance issue.
In addition, Jeff, I suggest you call Worksheet.EnableCalculation = False.
This will disable the recalculation of the sheet, and may accelerate the
import process.
http://msdn2.microsoft.com/en-us/library/aa214565(office.11).aspx
Does your target worksheet contain a lot of function(UDF) to be calculated?
If Visible is set to true, is there any dialog popped up on your side when
the ImportDataFromFile is processed?
Again, I am sorry for the inconveniences caused by the newsgroup system. I
have reported the system problem to the system owner through internal
channels. They will look into it and fix the problem.
Regards,
Jialiang Ge (jialge@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
- Follow-Ups:
- RE: Excel Calculation is faster when visible than when Visible=Fal
- From: Jialiang Ge [MSFT]
- RE: Excel Calculation is faster when visible than when Visible=Fal
- References:
- Excel Calculation is faster when visible than when Visible=False?
- From: JeffDotNet
- RE: Excel Calculation is faster when visible than when Visible=False?
- From: Jialiang Ge [MSFT]
- RE: Excel Calculation is faster when visible than when Visible=False?
- From: Jialiang Ge [MSFT]
- RE: Excel Calculation is faster when visible than when Visible=Fal
- From: Jialiang Ge [MSFT]
- Excel Calculation is faster when visible than when Visible=False?
- Prev by Date: RE: Excel 2000 Duplicate Shortcut Keys
- Next by Date: Get macros in Excel to show up as text always on the toolbar?
- Previous by thread: RE: Excel Calculation is faster when visible than when Visible=Fal
- Next by thread: RE: Excel Calculation is faster when visible than when Visible=Fal
- Index(es):
Relevant Pages
|