Glue42Office

1.4.9

The Glue42 MS Office Connectors allow you to:

Use Excel with its familiar functionality, such as macros and pivot tables, to create sophisticated calculations, or continue using those that may have accumulated over the years, while being able to save all data edits to your web app in real time.

Edit and format a document in Word, including WordArt, tables and drawings, making use of the familiar and powerful capabilities of the most popular text processing tool in the world.

Send and receive emails and manage tasks from web applications using all the familiar capabilities of Outlook.

Referencing

The glue4office library is available both as an npm module and as a standalone transpiled JavaScript file in %LocalAppData%\Tick42\GlueSDK\Glue4OfficeJS\js\web.

Because the API evolves, we have chosen the following semantic version model:

BreakingChangesVersion.FeatureVersion.FixVersion

You can reference the library in a <script> tag:

<script type="text/javascript" src="glue4office-1.4.9.js"></script>

When deploying your application in production, we recommend that you always reference a specific minified version:

<script type="text/javascript" src="glue4office-1.4.9.min.js"></script>

The browserified JavaScript file is also a CommonJS module, which you can require/import.

CommonJS:

const Glue4Office = require("glue4office");

ES6:

import Glue4Office from "glue4office";

Initialization

When you reference the standalone JavaScript file, it will expose a global factory function called Glue4Office.

If you have imported or required the library, the function will be available with the name you specified in the import or require statement.

Assuming you stick to the default Glue4Office name, to initialize the library, you need to call the function Glue4Office and specify which MS Office apps you want to interoperate with. The function returns a Promise, which will resolve with an initialized instance of the library.

Example:

const g4oConfig = {
  application: "MS Office Interop",
  excel: true, // enable Excel interop
  word: true, // enable Word interop
  outlook: false // disable Outlook interop
};
Glue4Office(g4oConfig)
  .then(g4o => {
    // g4o is a reference to the Glue4Office API
    window.g4o = g4o; // expose g4o as a global variable
    // use g4o
  })
  .catch(console.error);

See also the Connectors documentation for more details.

object

Description

Glue4Office API as returned from Factory function. Use this to object to interact with office products.

methoddone
() => Promise<void>

Description

Shutdowns glue. This will remove all Interop methods and streams registered by the application

Returns

Promise<void>

Properties

Outlook API. Use to interact with Outlook

Excel API. Use to interact with Excel

Word API. Use to interact with Word

string

Version of the API

Connection

Logger library

Agm library

Bus library

Metrics library

Contexts library

() => void

Brings up GD feedback dialog

object

Info object containing versions of all included libs and glue itself

string

Glue version

object

Description

Configuration object used to initialize Glue4Office

Properties

boolean

Outlook configuration. If false the library is not initialized and can not be used. Default is true.

boolean

Excel configuration. If false the library is not initialized and can not be used. Default is true.

boolean

Word configuration. If false the library is not initialized and can not be used. Default is true.

string

Application name. If not specified the value depends on the hosting environment:

  • in browser - document.title + random number (e.g., ClientList321333)
  • in HC - containerName + browserWindowName (e.g., Internal.ClientList)

/** Configurations for GW connection */
{
    
    /** Url for the WebSocket connections to the gateway */ 
ws: string; /** Url for the http connections to the gateway */
http: string; /** Version of the gateway that you’re connection to. Possible values are: 1, 2, 3 */
protocolVersion: number; /** * Reconnect interval in milliseconds. * Default is 500. */ /** * Reconnect interval in milliseconds. * Default is 500. */
reconnectInterval: number; /** * Number of reconnect attempts. * Default is 10. */ /** * Number of reconnect attempts. * Default is 10. */
reconnectAttempts: number; /** A way to pass custom token provider for gateway V3 tokens */
gwTokenProvider: { get: () => string; }; /** * Connect to a gateway running in the same process (you can spin off one by using tick42-gateway package) * Works only if protocolVersion is 3 */ /** * Connect to a gateway running in the same process (you can spin off one by using tick42-gateway package) * Works only if protocolVersion is 3 */
inproc: { /** Token returned when starting gateway from tick42-gateway package */
token: {}; /** Facade object - this is the default export of tick42-gateway */
facade: GW3Facade; }; /** * if protocolVersion == 3, used to create the connection's replayer * property; allows out-of-band subscription and replaying of Glue * messages */ /** * if protocolVersion == 3, used to create the connection's replayer * property; allows out-of-band subscription and replaying of Glue * messages */
replaySpecs: MessageReplaySpec[]; /** If true (default false) will always connect to GW, no matter what env the app runs in */
force: boolean; };

Configurations for GW connection

/** Contains metrics configurations */
boolean | {
    /**
     * Metrics system, if not specified defaults to:
     * - browser - ‘Browser’
     * - HC - 'HtmlContainer’ + container_name
     */
    /**
             * Metrics system, if not specified defaults to:
             * - browser - ‘Browser’
             * - HC - 'HtmlContainer’ + container_name
             */ 
system: string; /** * Metrics service, if not specified defaults to: * - browser - document.title || 'unknown’ * - HC - 'JS.’ + browser_window_name */ /** * Metrics service, if not specified defaults to: * - browser - document.title || 'unknown’ * - HC - 'JS.’ + browser_window_name */
service: string; /** * Metrics instance, if not specified defaults to: * - browser - ’~’ + random_number * - HC - ’~’ + machine_name */ /** * Metrics instance, if not specified defaults to: * - browser - ’~’ + random_number * - HC - ’~’ + machine_name */
instance: string; /** * If false (default) an App system will be created on top level, and all other metrics will live in it * If true App system will be created, and all metrics will live on top level */ /** * If false (default) an App system will be created on top level, and all other metrics will live in it * If true App system will be created, and all metrics will live on top level */
disableAutoAppSystem: boolean; };

Contains metrics configurations

boolean

boolean

/** Defines logger levels per output target */
{
    
    /** Console log level */ 
console: string; /** File log level */
publish: string; /** Metrics log level */
metrics: string; };

Defines logger levels per output target

/**
  * Authentication can use one of the following flows:
  * * username/password
  * * token - access tokens can be generated after successful login from the Auth Provider (e.g Auth0)
  * * gatewayToken - gateway tokens are one off, time limited tokens generated from GW after explicit request. To generate one use `glue.connection.authToken()` method
  */
{
    
    /** Username to be used */ 
username: string; /** Password to be used */
password: string; /** Authenticate using token generated from the auth provider. */
token: string; /** Authenticate using gatewayToken */
gatewayToken: string; } | string | number;

Authentication can use one of the following flows:

  • username/password
  • token - access tokens can be generated after successful login from the Auth Provider (e.g Auth0)
  • gatewayToken - gateway tokens are one off, time limited tokens generated from GW after explicit request. To generate one use glue.connection.authToken() method

function

(config: Config) => Promise<Glue4Office>

Description

Factory method used to create a new Glue4Office (G4O) instance. It is exposed as global object (called Glue4Office) when running in the browser or returned from module require when running in NodeJS. This should be the entry point of your G4O usage.

Parameters

Name
Type
Required
Description

config

no

Returns

Promise<Glue4Office>

Example

Glue4Office({
  gateway: {
    ws: "ws://localhost:8080/gw",
    protocolVersion: 3
  },
  auth: {
    username: "myUsername",
    password: "myPassword"
  }
})
  .then(glue4office => {
    console.log(glue4office.version);
  })
  .catch(error => {
    console.warn(error);
  });