Spread.Sheets supports the UMD (Universal Module Definition) patterns for JavaScript modules that work everywhere.
Typically, the UMD pattern in Spread.Sheets includes support for AMD (Asynchronous Module Dependency) and CommonJS, which are module specifications that enable developers to write code in a modular way. The modular programming done using UMD patterns not only helps in achieving code reusability but also enhances code efficiency while saving considerable amount of time and resources. Besides this, it can help you in providing solutions to some of the common programming problems without any dependency of writing scripts in a certain order while coding in JavaScript.
UMD patterns are supported for the following six javascript files in Spread.Sheets:
The AMD (browser-first) dependencies can be asynchronously loaded to avoid a situation where the browser is likely to loose response.
The following code shows how to configure RequireJS, initialize Spread.sheets using AMD and using Excel IO Spread with AMD.
JavaScript |
Copy Code
|
---|---|
// Configuring RequireJS <script type="text/javascript"> // Initializing SpreadJS and ExcelIO <script type="text/javascript"> function SaveExcel(){ |
The Common JS (server-first) dependencies makes the javascript code run in the integrated development environment(IDE).
The following code shows how to initialize Spread.Sheets using Common JS.
JavaScript |
Copy Code
|
---|---|
var gc = require('../lib/gc.spread.sheets.all.x.x.x.min.js'); window.onload = function() { var gc = require('../lib/gc.spread.sheets.all.x.x.x.min.js'); window.onload = function() { |