Hoppa till huvudinnehållet

Reading Excel File from File Picker

Kommentarer

3 kommentarer

  • Permanently deleted user

    Ok, so I've gotten it to work so far, but now I'm stuck returning a promise rather than the workbook and am not sure how to resolve it in Geocortex. Below are the two functions I'm using to do the processing. In the final export default class, I'm just calling "caller(inputs.excelFile)" and returning it.

     

     

    import Excel from 'exceljs'

     

    function getWorkbookFromFile2 (excelFile: Blob) {

        return new Promise((resolve) => {

            const reader = new FileReader();

     

            reader.onload = (event) => {

                const data = event.target!.result as Buffer;

                const loader = new Excel.Workbook();

     

                const workbook= loader.xlsx.load(data!);

     

                resolve(workbook);

            };

            reader.readAsArrayBuffer(excelFile);

        });

    }

     

    async function caller(file: Blob) {

    const workbook = await getWorkbookFromFile2(file);

    return workbook;

    }

    0
  • Permanently deleted user

    Ok, so I've made a few tweaks and have been able to get at the result in the Workflow. So, now I've done some processing in the script so that it ends up returning a query string that I can input into a Query Activity.

     

    So far, this works, however; after the Query returns it's result of features, the whole program kind of freezes and different Errors keep popping up in the console saying something along the lines of:

     

    Unhandled promise rejection TypeError: e.loadPromise.isResolved is not a function

      at ViewerApplication.o._canBeLoaded (Framework.bundle.js:1)

      at Framework.bundle.js:1

      at Array.filter (<anonymous>)

      at ViewerApplication.o._findUnloadedModulesForCommand (Framework.bundle.js:1)

      at ViewerApplication.o.pendingModulesForCommand (Framework.bundle.js:1)

      at a.execute (Framework.bundle.js:1)

      at Framework.bundle.js:1

      at eval (exceljs.min.js?e8ae:11)

     

    0
  • Permanently deleted user

    On further testing, I'm able to zoom to the features if it goes quickly. It seems like something is continuing to be called and if the workflow takes too long, it starts throwing the promise error.

     

    When I try to add the query results to the results pane, I guess it takes slightly longer and starts throwing the Promise.isResolved is not a function error before the results are added.

    0

Du måste logga in om du vill lämna en kommentar.