RE: Does SheetJs work in netsuite serverside script

Hi All, I am trying to use sheetJs with NS? Does it work in serverside script within NS?

samyt Rookie Asked on December 11, 2019 in SuiteScript.
Add Comment
2 Answers
Best answer

I think SheetJS is not AMD-compatible by default, I had to shim ( it in with require config file corresponding to the @NAmdConfig JSDoc tag.

I have gotten it to work serverside in the past though if you just wanted some encouragement to invest time into that route 🙂

Intermediate Answered on December 11, 2019.

Thanks. Do you have any sample code which I can use for reference?

on December 11, 2019.

It was quite a while since I looked at it. If I recall correctly, I ended up needing to use the .core version for some reason and even then I had to go in and edit some source code in order to make certain things work serverside…my understanding of requirejs was lesser at that time though, so it might be done better/easier now.
This was the config setup though if that helps:


"baseUrl": "SuiteScripts/.../Libraries/",

"paths": {

"XLSX": "xlsx.core.min"


"shim": {

"XLSX": {

"exports": "XLSX"




on December 11, 2019.

Thanks. This works too. Even I am not so great with requireJs 🙁

on December 11, 2019.

I’m trying to get this to work with no  luck.

Here is the header of my Suitelet:


 *@NApiVersion 2.x

 *@NScriptType Suitelet

 *@NModuleScope Public

 *@NAmdConfig  ../Libraries/xlsx.json



Here is the .json file:


    “baseUrl”: “SuiteScripts/xxx/Libraries/”,

    “paths”: {

    “XLSX”: “xlsx”


    “shim”: {

        “XLSX”: {

            “exports”: “XLSX”





Here is the code in my Suitelet:

var wb = xlsx.utils.book_new();

       wb.Props = {

        Title: fileName,

        Subject: fileName,

        Author: “”,

        CreatedDate: new Date()



       var ws = xlsx.utils.aoa_to_sheet(rows);

       wb.Sheets[fileName] = ws;

       //var wbout = XLSX.write(wb, {bookType:’xlsx’,  type: ‘binary’});


       const result = xlsx.write(wb, {

        BookType:’xlsx’, // output file type

        Type:’buffer’, // data type of output

        Compression: true // turn on zip compression


        var result = xlsx.write(wb, {bookType:”xlsx”, type:’base64′});

        var fileObj = file.create({

            name: fileName + ‘-‘ + dateString + ‘.xlsx’,

            fileType: file.Type.EXCEL,

            contents: result,

            folder: netsuiteFolder


I’m getting an error on the first ine that it can’t find utils from undefined.


Thank you for the help




on December 19, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.