Skip to main content

AMD (define)

Each standalone release script is available at https://cdn.sheetjs.com/.每个独立版本脚本都可以在https://cdn.sheetjs.com/上获得。

xlsx.full.min.js supports AMD with name xlsx out of the box.支持名为xlsx的AMD。


note

When referencing by file name, AMD loaders typically omit the file extension.当按文件名引用时,AMD加载程序通常会忽略文件扩展名。

The actual file name is xlsx.full.min.js, but the examples will refer to the script as xlsx.full.min.实际文件名是xlsx.full.min.js,但示例将脚本称为xlsx.full.min

NetSuite

After downloading the script, it can be referenced directly in define calls in SuiteScripts:下载脚本后,可以在SuiteScripts中的define调用中直接引用该脚本:

define(['N/file', './xlsx.full.min'], function(file, XLSX) { 
// ... use XLSX here
})

As explained in the NetSuite demo, module aliases are created in config files referenced via @NAmdConfig comments.NetSuite演示中所述,模块别名是在通过@NAmdConfig注释引用的配置文件中创建的。

SAP UI5

After downloading the script, it can be uploaded to the UI5 project and loaded in the sap.ui.define call:下载脚本后,可以将其上载到UI5项目并加载到sap.ui.define调用中:

sap.ui.define([ 
/* ... other libraries ... */
"path/to/xlsx.full.min"
], function(/* ... variables for the other libraries ... */, XLSX) {
// use XLSX here
})
warning警告

The SAP Website has a note about including third-party JS libraries. SAP网站上有一条关于包含第三方JS库的说明。It recommends copying and pasting JavaScript code.它建议复制和粘贴JavaScript代码。

Copy and pasting code does not work复制和粘贴代码无效 for SheetJS scripts as they contain Unicode characters that may be mangled. 对于SheetJS脚本,因为它们包含可能会损坏的Unicode字符。The standalone script should be downloaded and manually uploaded to the project.应下载独立脚本并手动上载到项目中。

RequireJS

After downloading the script, it can be referenced directly in require calls:下载脚本后,可以在require调用中直接引用它:

require(['./xlsx.full.min'], function(XLSX) { 
// ... use XLSX here
});

Aliases别名

The requirejs.config function can define aliases through the paths key:requirejs.config函数可以通过paths键定义别名:

requirejs.config({ 
paths: {
xlsx: [ './xlsx.full.min' ]
}
});

Once that is set, app code can freely require xlsx:设置后,应用程序代码可以自由要求xlsx

require(['xlsx'], function(XLSX) { 
// ... use XLSX here
});