Glue4Office
1.6.5The 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.6.5.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.6.5.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.
APIobject
Description
Glue4Office API as returned from Factory function. Use this to object to interact with office products.
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
agm | API | Interop library. |
||
bus | API | Pub/Sub library. |
||
connection | API | Connection library. |
||
contexts | API | Contexts library. |
||
excel | API | Excel API. Use to interact with Excel |
||
feedback | (info?: FeedbackInfo) => void | Brings up the Glue42 Desktop feedback dialog. |
||
info | object | Info object containing versions of all included libraries and Glue42 itself. |
||
interop | API | Interop library. |
||
logger | API | Logger library. |
||
metrics | API | Metrics library. |
||
outlook | API | Outlook API. Use to interact with Outlook |
||
version | string | Version of the API |
||
word | API | Word API. Use to interact with Word |
Methods
donemethod
Signature
() => Promise<void>
Description
Disposes Glue42 API. This will remove all Interop methods and streams registered by the application.
Configobject
Description
Configuration object used to initialize Glue4Office
Properties
Property | Type | Default | Required | Description |
---|---|---|---|---|
agm | boolean | Enable or disable the Interop API. |
||
application | string | Application name. If not specified, the value depends on the hosting environment.
For the browser - |
||
auth | string | Auth | Authentication can use one of the following flows:
|
||
bus | boolean | Enable or disable the Pub/Sub API. |
||
customLogger | CustomLogger | |||
excel | boolean | Excel configuration. If false the library is not initialized and can not be used. Default is true. |
||
gateway | GatewayConfig | Configurations for the Glue42 Gateway connection. |
||
glue | GlueCore | |||
logger | string | LoggerConfig | Defines logging levels per output target. |
||
metrics | boolean | MetricsConfig | Metrics configurations. |
||
outlook | boolean | Outlook configuration. If false the library is not initialized and can not be used. Default is true. |
||
word | boolean | Word configuration. If false the library is not initialized and can not be used. Default is true. |
Glue4Officefunction
Signature
(config?: Config) => Promise<API>
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 | Config |
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);
});