• Resources
    • Documentation
    • Knowledge Base
    • Forum
    • Webinars and Videos
    • Courses
    • FAQ
    • Changelog
    • Blog
    • Swag Shop
  • Marketplace
  • Login
  • Resources
    • Documentation
    • Knowledge Base
    • Forum
    • Webinars and Videos
    • Courses
    • FAQ
    • Changelog
    • Blog
    • Swag Shop
  • Marketplace
  • Login
home/Knowledge Base/How to's/Full-Text Search For Excel Files

Full-Text Search For Excel Files

217 views 0

Written by Christian Kleinschroth
April 21, 2021

Prerequisites

You need sheet.js available as external library on your Simplifier instance:

Please refer to this Knowledge Base article to learn how to integrate external libraries.

Step 1 – Client-side Business Object

Create a client-side Business Object (BO) function call for implementing the logic of the full-text search:

// input: 'file' (Any), 'searchValue' (String)
// output: 'result' (Boolean)
var reader = new FileReader();
reader.onloadend = function() {
    var data = new Uint8Array(reader.result);
    var workbook = XLSX.read(data, {
        type: 'array'
    });
    var result = false;
    for (var i = 0; i <= workbook.SheetNames.length-1; i++) {
        var currentSheet = workbook.Sheets[workbook.SheetNames[i]]
        var rowObj = XLSX.utils.sheet_to_row_object_array(currentSheet);
        var jsonObj = JSON.stringify(rowObj) ;
        var re = new RegExp(oPayload.searchValue);
        result = re.test(jsonObj);
        if (result) {
            break;
        }
    }
    fnSuccess({
        result: result
    });
};
reader.readAsArrayBuffer(oPayload.file);

Step 2 – Application Editor: Add sheet.js As External Library

Add sheet.js as external library to your Simplifier app (Knowledge Base article):

Step 3 – UI Designer: User Input

Use the FileUploader (1) widget, so that the user can select a Excel file to analyze. In addition, add an Input (2) widget for entering the search value. With the ‘search’-Button (3) the user starts the full-text search.

Step 4 – Process Designer: Story

Create a story for the workflow:

  1. Subscribe to ‘search’-Button’s press event
  2. Extract file from FileUploader using a script block:
    // replace "FileUploader" with the ID of your FileUploader widget
    var uploaderInput = this.getView().byId("FileUploader");
    
    if (uploaderInput.getValue() !== "") {
        var files = uploaderInput.oFileUpload.files;
    
        if (files.length === 1) {
            var file = files[0];
        }
    }
    // create a global variable "uploaderFile" (String) to store the file 
    this.getGlobals().setVar("uploaderFile", file);
  3. Use your client-side ‘fullTextSearch_Excel’ function call from Step 1 to get the result of the full-text search
    1. Input: ‘uploaderFile’,  search ‘value’ (input widget)
    2. Output: full-text search ‘result’

Step 4 – Result

To display the result you can use an ObjectStatus widget and specify the state and icon property with a condition shape in the process designer (1):

  1. status = ‘Success’ in case of a positive result (true) (2)
  2. status = ‘Error’ in case of a negative result (false) (3)

Was this article helpful?

Yes  No
Related Articles
  • REST: Use a CSRF Token and a Cookie to authorize Requests
  • Use the Adobe PDF Embed API in your Simplifier Application
  • Simplifer setup with recommended environment using docker-compose
  • Logs and Monitoring in Simplifier
  • Version and Release Management in Simplifier
  • Dynamic where-clause and repeatable statement
Leave A Comment Cancel reply

You must be logged in to post a comment.

Latest Articles
  • REST: Use a CSRF Token and a Cookie to authorize Requests
  • Use the Adobe PDF Embed API in your Simplifier Application
  • Process Designer: Keeping an overview
  • Contact | Imprint | Privacy | © 2022 Simplifier AG. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.