Error when using with Node.js: ReferenceError: HTMLElement is not defined

Posted by: ken-sugiyama on 2 December 2024, 6:04 am EST

    • Post Options:
    • Link

    Posted 2 December 2024, 6:04 am EST - Updated 2 December 2024, 6:31 am EST

    Hello.

    I’m trying to get SpreadJS to work with Node.js.

    I tested whether the attached sample code works with version 17.1.10.

    However, I encountered the following error:

    ReferenceError: HTMLElement is not defined

    The same error also occurred with version 17.1.5.

    It seems to work with version 17.0.10. Do you have any idea what might be causing this error?

  • Posted 2 December 2024, 6:39 am EST

    Hi,

    Please include the following lines in your sample:

    global.HTMLElement = window.HTMLElement;
    global.HTMLDivElement = window.HTMLDivElement;
    global.customElements = null;

    You can refer to the updated blog post on importing and exporting XLSX files using SpreadJS for more information: https://developer.mescius.com/blogs/how-to-import-export-excel-xlsx-using-node-js

    Additionally, please note that license information is confidential and should not be shared on public forums. As a result, I have removed the sample from this forum case.

    Attached is a modified sample that you can use in your application. Kindly ensure to set valid license keys for SpreadJS and ExcelIO before running the attached sample, as the provided sample does not include them.

    If your sample contains confidential data, I recommend creating a case on our private portal at: https://developer.mescius.com/my-account/my-support

    Further, ExcelIO is an old module used for import/export and the developers recommend using the new SJSIO module for import/export. Refer to the following demo on Import/Export that uses the new SJSIO Module: https://developer.mescius.com/spreadjs/demos/features/spreadjs-file-format/overview/purejs

    Feel free to reach out if you encounter any issues.

    Best regards,

    Ankit

    nodejs_sample.zip

  • Posted 3 December 2024, 12:05 am EST

    Hi,

    Thank you very much. I was able to export it.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels