Splunk Dev

Why won't External library sheetjs load in Splunk javascript?

joshiro
Communicator

Hi, we're trying to import sheetjs into a custom SplunkJS script so we can export some results into xlsx.
Tried to add it in the required section at the begining of the script but is not working.

 

require([
    "splunkjs/mvc",
    "<path to xlsx.full.min.js>",
    "splunkjs/mvc/searchmanager",
    "splunkjs/mvc/simplexml/ready!"
    ], function(
        mvc,
        XLSX,
        SearchManager)
    {
        console.log(XLSX.version);
    }
);

 

 
Here is the sheetjs documentation: https://github.com/SheetJS/sheetjs
Any help ll be appreciated.

Regards.

Javier.

Labels (1)
Tags (1)
1 Solution

fralcalde
Explorer

After several hours of trial and error we managed to get sheetjs to work in a dashboard script with requirejs.

The solution was to set the require.config settings like follows:

 

require.config({
    paths: {
        'xlsx': '/static/app/my_app/sheetjs/dist/xlsx.full.min'
    }
});

 

 
And then load it:

 

require([
    "splunkjs/mvc",
    "splunkjs/mvc/searchmanager",
    "xlsx",
    "splunkjs/mvc/simplexml/ready!"
    ], function(
            mvc,
            SearchManager)
    {
        console.log(XLSX.version);  
    }
);

 


I am new to requirejs and javascript in general, but this way it worked. If anyone cares to explain why, we thank you.

 

View solution in original post

fralcalde
Explorer

After several hours of trial and error we managed to get sheetjs to work in a dashboard script with requirejs.

The solution was to set the require.config settings like follows:

 

require.config({
    paths: {
        'xlsx': '/static/app/my_app/sheetjs/dist/xlsx.full.min'
    }
});

 

 
And then load it:

 

require([
    "splunkjs/mvc",
    "splunkjs/mvc/searchmanager",
    "xlsx",
    "splunkjs/mvc/simplexml/ready!"
    ], function(
            mvc,
            SearchManager)
    {
        console.log(XLSX.version);  
    }
);

 


I am new to requirejs and javascript in general, but this way it worked. If anyone cares to explain why, we thank you.

 

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...