This is somewhat OT but you're such an expert when it comes to Excel files I thought you might have some insights.
I'm using Flexcel to create an Excel file. I then use ShellExecute to open the file in the default applications (normally Excel). The opening of the file normally happens quickly and Excel, if not already open, usually starts to load instantly.
Yesterday I upgraded to Windows 10.
Everything seemed fine until I exported one of my Excel file. Now it takes about 45 seconds from the file being created before Excel loads. Here's a video:
I don't know what else to suggest, but maybe you can try using 0 or hinstance as the first parameter of ShellExecute and see if there is a difference? And see if disabling windows defender changes something? I imagine that if you start Excel manually it starts fast?
Just for the record, the full source code is as follows:
unit Unit12;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VCL.FlexCel.Core, FlexCel.XlsAdapter,
Vcl.StdCtrls;
type
TForm12 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form12: TForm12;
implementation
uses IOUtils, ShellAPI;
{$R *.dfm}
procedure TForm12.Button1Click(Sender: TObject);
var
xls: TXlsFile;
r, c: integer;
fname: string;
begin
fname := TPath.Combine(TPath.GetDocumentsPath,'cdata.xlsx');
xls := TXlsFile.Create(1, true);
try
for r := 1 to 10000 do
begin
for c := 1 to 30 do
begin
xls.SetCellValue(r, c, random);
end;
end;
xls.Save(fname);
finally
xls.Free;
end;
ShellExecute(0, 'open', PChar(Fname), '', '', SW_SHOWNORMAL);
end;
end.
I've tried it on a colleagues machine who is running Windows 10. He has no problem opening Excel almost instantly. So it looks like a problem which is local to my machine.
Interesting, I wonder what strange mix of stuff might be causing this. Office 2013 is kind of strange because it has to have all the subscription checks to see if you are entitled to use it or if your subscription has expired, it might be related to that.
But other thing I had noticed, which also applies at least to windows 8 and also to Excel 2010 is the following:
If you are debugging an application (it might be from visual studio or from delphi, it doesn't matter) and you are stopped in a breakpoint, then double clicking an xls/x file in the file explorer takes forever to open.
It happens as said also in windows 8, and in Excel 2010 too. It is interesting, because if you first open Excel from the start menu, then double click the xls/x file, it will open instantly. But if Excel is not open and you happen to have some code stopped in a breakpoint, it will take forever. I know it happens to me all the time when debugging FlexCel, and every time it gets some swear words from me.