How to alter the name of downloadable excel sheet of webform Issue:

When I click on the link ofwebform Download as shown in below screenshot the default name of excel sheet before save to local disk appears like localhost_worklog.xlsx but I want something like localhost_worklog_02172017.xslx which is appended with _&lt;current time&gt;.

SCREENSHOT:



EDIT: After using iLLin's answer



Problem: How can I alter the name of localhost_worklog.xlsx before save?

I am using drupal 7.53.
The only way to do this is to change the $node-&gt;title on the loaded object for the webform.  That filename uses that title, so I am assuming you have a webform title of "Localhost Worklog".

The problem with that is you only want to change the node title, when you are downloading the webform (or atleast running through that process).

You have two options (I think).  You could implement a hook_entity_load() function and then check if the URL is

node/%webform_menu/webform-results/download
or

node/%webform_menu/webform-results/download-file

function MYMODULE_entity_load($entities, $type) {
  if (arg(2) == 'webform-results' &amp;&amp; (arg(3) == 'download' || arg(3) == 'download-file')) {
    foreach ($entities as $entity) {
      $entity-&gt;title = $entity-&gt;title .'_'. now();
    }
  }
}


Docs

The other way I can think of is altering the page callback with a hook_menu_alter(), changing the title there and then calling their function to return the form or download file with the updated node object to include the time appended to the title.

EDIT

From reviewing your update, it seems it's changing the title too soon on that page.  So I think you will need a combo approach.  Using hook_entity_load and hook_form_alter.  The point is changing that title in the $node object that is passed around for download.  So try this.

/*
 * Implements hook_entity_load().
 */
function MYMODULE_entity_load($entities, $type) {
  // Change the node title to include the time when downloading.
  if (arg(2) == 'webform-results' &amp;&amp; arg(3) == 'download-file') {
    foreach ($entities as $entity) {
      $entity-&gt;title = $entity-&gt;title .'_'. now();
    }
  }
}

/*
 *  Implements hook_form_alter().
 */
function MYMODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == WEBFORM_DOWNLOAD_FORM_ID) {
    // Change the node title that is passed around for download.
    // @TODO: Check to make sure this is correct.
    $form['node']['#value']-&gt;title = $form['node']['#value']-&gt;title . '_'. now();
  }
}