Adding the Export to Excel Feature to a JavaScript Search Page With the Legacy Interface Editor

Coveo for Salesforce 2.6 - November 2015 

Coveo JavaScript Search Framework 1.0.139 - November 2015 

REST Search API 8.0.885 - November 2015 

NewFeature-ExportToExcel1 The JavaScript Search Framework (bundled with Coveo for Salesforce or standalone) offers a feature allowing users to export the 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 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. Previously, the file contained the field values only for the search results of the currently displayed such page, typically 10.

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

Coveo for Salesforce 2.26 - July 2016  A newer Coveo JavaScript Search Interface Editor replaces the legacy Interface Editor described in this topic (see JavaScript Search Interface Editor).

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

  1. Using an administrator account, access the JavaScript Search page to which you want to add Export to Excel option.

  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. Open the Interface Editor (see Accessing the Coveo Legacy Interface Editor in Salesforce or Accessing the Coveo Interface Editor).

  4. You must add the ExportToExcel component (see ExportToExcel Component) to the HTML markup of the page:

    1. Depending on the Interface Editor version, access the search page code view:

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

      • In the Legacy Interface Editor, select the Advanced Mode check box, and then click the Code tab.

    2. In the HTML markup:

      1. When adding the feature to a Coveo for Salesforce Insight Panel, 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>
             <div class="CoveoSearchbox" data-enable-omnibox="true">
             </div>
           </div>
        
      2. Locate the div with the CoveoSettings class and add the .CoveoExportToExcel value to its 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.

      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.

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

        Technically, the div can be anywhere under the main div (with the CoveoSearchInterface class) of the page.

    3. Depending on the Interface Editor version, access the search page UI view:

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

      • In the Legacy Interface Editor, click the Components tab.

    4. In the search interface, click the Settings button on the right of the search box to validate that the Export to Excel option is now available.

  5. Depending on the Interface Editor version, make your changes available:

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

    • In the Legacy Interface Editor, click the Draft tab, and then Publish Draft button.

  6. In the published search interface, perform a search, click the Settings button, and then click the Export to Excel option.

    A Microsoft Excel file is built and downloaded containing up to 100 (or custom number) search results.

  7. Open the downloaded Microsoft Excel file, and review the data.