Adding the Export to Excel Feature to a JavaScript Search Page

Coveo for Salesforce 2.26 - July 2016 

The JavaScript Search Framework (bundled with Coveo for Salesforce or standalone) offers a feature allowing end-users to export search results to a Microsoft Excel spreadsheet (.xlsx file). The Excel file contains the values for all the fields of the exported search results.


Exporting search results to Excel may be useful to many users, allowing them to leverage the search interface to easily create information lists (see Exporting Search Results to Microsoft Excel from a JavaScript Search Interface).

The Export to Excel option is typically included within the Settings component that exposes a button on the right of the search box.

  • Coveo for Salesforce 2.26 - July 2016  The new Interface Editor is described in this topic. Prior Coveo for Salesforce versions include a Legacy Interface Editor (see Adding the Export to Excel Feature to a JavaScript Search Page With the Legacy Interface Editor).

  • When using Microsoft Edge, you cannot export a query that contains over 1,000 characters. You are encouraged to use another browser.

  • Coveo JavaScript Search Framework 1.0.318 - February 2016 

    With this version:

    • The Export to Excel option is available by default in the search interface sample files included in the package.

    • The Excel file contains the field values of the first 100 search results of the current query sorted by Relevance. In previous versions, the file contains the field values only for the search results of the currently displayed search page which is typically 10.

    • You can specify the maximum number of search results to export using the data-number-of-results attribute of the exportToExcel component.

To add the Export to Excel option to a JavaScript search page

  1. Using an administrator account, navigate to the Coveo search page for which you want to create a search result template, and then access the Interface Editor (see Accessing the Interface Editor from Coveo Cloud V2 Hosted Search Pages or Accessing the Interface Editor in Coveo for Salesforce V2).

  2. Ensure that the JavaScript Search Framework powering your search page is version 1.0.139+, preferably version 1.0.318+ to get the latest options (see Identifying the Coveo JavaScript Search Version).

  3. Add the ExportToExcel component to the HTML markup of the page (see ExportToExcel Component):

    1. In the Interface Editor, in the upper-right corner, click the Code View tab.

    2. In the HTML markup:

      1. Add/locate the div with the coveo-search-section class containing a div with the CoveoSettings class.

         <div id="search" class="CoveoBox" data-design="new">
           <div class="coveo-search-section">
             <div class="CoveoSettings">
             <div class="CoveoSearchbox" data-enable-omnibox="true">
      2. In the div with the CoveoSettings class, add the .CoveoExportToExcel value to the data-include-in-menu attribute:

         <div data-include-in-menu=".CoveoShareQuery,.CoveoExportToExcel,.CoveoPreferencesPanel" class="CoveoSettings">

        The order of the attribute values determines the order of appearance of the options in the menu. Therefore, the option corresponding to the last attribute value is displayed at the top of the menu.

      3. Add the following div under the div with the CoveoSearchbox class:

         <div class="CoveoExportToExcel" data-number-of-results="100"></div>

        where you can set the maximum number of exported search results using the data-number-of-results attribute.

        • This div can be anywhere under the main div (with the CoveoSearchInterface class) of the page.

        • When the default value is 100, the export creation takes about 1 second to complete. Increasing the value progressively increases the time needed to create the export file. It is not recommended to go above 1000, which is the index default maximum number of results.

  4. In the Interface Editor, in the upper-right corner, click the UI View tab.

  5. In the search interface, click the More icon (Icon-Settings) on the right of the search box to validate that the Export to Excel option is now available.

  6. In the Interface Editor, in the upper-right corner, click Save.

  7. In the published search interface, perform a search, click the More icon (Icon-Settings), and then click the Export to Excel option.

    A Microsoft Excel file is built and downloaded containing the number of search results you specified.

  8. Open the downloaded Microsoft Excel file, and then review the data.