Opening an Excel xlsx file in Windows 10?

Hi Adrian,

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:

This is strange! Do you know why this might be the case? Are there any other ways to open an Excel file?



P.S. I'm using Delphi XE7

I am not sure, but it looks like some antivirus thing to me?  Do you have any AntiVirus installed besides Windows Defender?

I've tried here with a simple program that creates a 10000x30 spreadsheet and then opens it, and it works fast:

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;


  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VCL.FlexCel.Core, FlexCel.XlsAdapter,

  TForm12 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    { Private declarations }
    { Public declarations }

  Form12: TForm12;

uses IOUtils, ShellAPI;

{$R *.dfm}

procedure TForm12.Button1Click(Sender: TObject);
  xls: TXlsFile;
  r, c: integer;
  fname: string;
  fname := TPath.Combine(TPath.GetDocumentsPath,'cdata.xlsx');
  xls := TXlsFile.Create(1, true);
    for r := 1 to 10000 do
      for c := 1 to 30 do
        xls.SetCellValue(r, c, random);

  ShellExecute(0, 'open', PChar(Fname), '', '', SW_SHOWNORMAL);



Hi Adrian,

Thanks for taking a look.

Still no joy. I get the delay with you small app as well:

Thanks - Steve

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.

Thank - Steve

Hi Adrian,

FYI looks like this is the problem

I've switched to OpenOffice as the default app and it now opens instantly.

- Steve

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.