/////////////////////////////////////////////////////////////////////////////////////////
//Create an Excel file on the desktop with the first 10 cells filled and ask to open it//
/////////////////////////////////////////////////////////////////////////////////////////
var
  Excel, WB, WS, Cell, i, Shell, Folder, FilePath, FolderItem;
begin
  
  Shell := CreateOleObject('Shell.Application');
  try
    Folder := Shell.Namespace(0);  
    FilePath := Folder.Self.Path + '\TwistpadExcelSample.xlsx';
  finally
    Folder := Unassigned;
    Shell := Unassigned;
  end;
    
  Excel := CreateOleObject('Excel.Application');
  try
    WB := Excel.Workbooks.Add;
    WS := WB.Worksheets[1];

    for i := 1 to 10 do
    begin
      Cell := WS.Cells[i, 1];
      Cell.Value := 'Cell ' + IntToStr(i);
      Cell := Unassigned;
    end;
    
    WB.SaveAs(FilePath);

    WB.Close(False);
    WB := Unassigned;
    WS := Unassigned;
  finally
    Excel.Quit;
    Excel := Unassigned;
  end;
    
  if MessageDlg('Open the created Excel file?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
  begin
    Shell := CreateOleObject('Shell.Application');
    try
      Folder := Shell.Namespace(0);  
      FolderItem := Folder.ParseName(ExtractFileName(FilePath));
      FolderItem.InvokeVerb('Open'); 
      FolderItem := Unassigned;
      Folder := Unassigned;
    finally
      Shell := Unassigned;
    end;
  end;
end;