Excel load time measurement

I have been looking for a solution for more than one week. Perhaps you have a good solution to this problem:

I want to measure the time I need to open an Excel file using Excel. My first solution is to start the measurement with this line of code:

ProcessBuilder command = new ProcessBuilder("cmd", "/c",
                        <EXCEL_PATH>,
                        <FILE-LOCATION>);
                command.start();
                long start = System.currentTimeMillis();

And I will check RAM-Usage through the process explorer. If the processing of the final results in excel mode still remains unchanged, I stop the measurement. As you can see, this is a very fuzzy and not very good solution.

As a second solution, I open SocketServer in JAVA and wait for Excel to call the Workbook_Open () method after the file has finished loading. As part of this method, I send a socket connection to a java server (I provide the host and port as an excel parameter) and measure this time.

This is very effective, but my company is not allowed to run scripts automatically if they are not stored in a trusted zone. I cannot change the policy, so this is not a solution. Does anyone know how to measure the load time of an Excel file in Excel? It may not be that there is no solution for tracking load times in Excel?

+4
source share
1 answer

Updated answer:

You can use DDE to attempt to reconnect (start a conversation) to the desired file and measure the time it takes until you succeed.

Please note that this will be far from an accurate measurement and should be used mainly for evaluation.

, , , DDE Java MS Excel.

:

Excel DDE , Excel, .
Excel DDE ( 100 ) , , .

:

ts = now(); 
d = DDE("file.xlsx"); 
while (d.error) { 
    d = DDE("file.xlsx"); 
} 
load_time = now() - ts;

</" > : VBA, , .

, , (Now) Workbook_Open, , .

, 2 .a >

+1

Source: https://habr.com/ru/post/1599871/


All Articles