Spire.OfficeJS is an online Office document editing suite that supports private deployment. It is also an embeddable online Office editor for developers and enterprises that need to integrate document editing into their own web applications. Users can open, view, edit, and save Word, Excel, and PowerPoint documents directly in the browser, and preview PDFs in read-only mode. No Microsoft Office, WPS, or browser plug-in is required on the client.

Rather than fragmented, low-level APIs, Spire.OfficeJS provides a JavaScript Office editor that can be embedded directly into business pages. The page loads SpireCloudEditor.js, prepares a container element, and passes in the configuration; the editor then loads the corresponding interface as an iframe. Document parsing, layout, rendering, and editing are handled by default by the in-browser WebAssembly document engine. This does not mean there is nothing to deploy, however: SpireCloudEditor.js, the editor UI, the WebAssembly engine, and resources such as fonts must still be hosted on a resource service that the browser can reach. For the full product composition and runtime architecture, see Product Composition and Runtime Architecture.

Key Features

  • Online editing: Online editing for Word, Excel, and PowerPoint documents; open, view, edit, and save documents in the browser, with "Download as" export.
  • PDF preview: Read-only PDF preview within the same interface.
  • Collaboration and review: Supports collaborative editing, comments, revisions, and document history.
  • UI customization: Supports appearance options such as the menu bar, toolbar, interface language, and multiple layouts, for flexible control over the interface.

Product Composition

Spire.OfficeJS ships three editor modules plus PDF preview, all sharing a single editor entry point and runtime:

Document Type Editor Module Document Engine Key Capabilities
Word documents web/editors/spiredocument Spire.Doc WebAssembly Open, view, edit, save, and "Download as"
Excel workbooks web/editors/spirespreadsheet Spire.Xls WebAssembly Open, view, edit, save, and "Download as"
PowerPoint presentations web/editors/spirepresentation Spire.Presentation WebAssembly Open, view, edit, save, and "Download as"
PDF documents — (provided by spiredocument) Spire.Pdf WebAssembly Read-only preview

Each editor module offers three interface layouts: desktop, mobile, and embed. For the complete list of supported formats, see Supported File Formats.

Typical Use Cases

Scenario Typical Requirement Role of Spire.OfficeJS
Document management systems Online preview, editing, and saving of Office files Open the editor directly beside the file list, cutting out uploads and downloads
OA, approval, and contract systems Annotations, revisions, permission control, and audit trails Control edit, comment, and download permissions by role; support review and history
Enterprise cloud storage and SaaS platforms Embed document capabilities into your own product Fit into existing branding and workflows through configuration and UI customization
Online education and training Assignment grading, courseware preview, and group discussion Online editing and comments, with read-only mode for presenting materials
Archives and knowledge bases Unified preview across multiple formats Open Word, Excel, PowerPoint, and PDF documents in a single interface

How It Differs from Self-Built and Public Cloud Solutions

Integrating document capabilities into a business system involves trade-offs whichever approach you take. First, the download–edit–re-upload workflow is fragmented. Second, building browser-side rendering and editing in-house is costly. Third, relying on server-side conversion adds load. And fourth, public cloud office suites make it difficult to fully align the interface, permissions, and data storage with your business system. Spire.OfficeJS handles document processing inside the browser, covers Word, Excel, PowerPoint, and PDF through a single entry point, and keeps both deployment resources and document data on your side through private deployment—making it well suited to scenarios with requirements around data location, UI branding, and deployment method.

Licensing

Spire.OfficeJS is a commercial component. The license file path is specified through a configuration file in the product package. For details on placing and activating the license, see Spire.OfficeJS License Configuration.

The comments feature in Spire.OfficeJS lets readers leave feedback on a specific passage without changing the body text. Comments are independent of revisions: they can be replied to, resolved, or removed without accepting or rejecting a revision. Using Word as an example, this article describes the comment operations that Spire.OfficeJS provides, and explains how to enable, restrict, or hide them as needed.

Comment Capabilities at a Glance

Comment entry points are available on the Insert and Review tabs, and in the floating button that appears after you select text. The comments pane lists every comment in the document in one place and provides centralized management.

Capability UI Location Description
Add comment Insert → Comment; floating button after selecting text Adds a comment to the selected text
Reply to comment Comment bubble or comments pane Appends a reply under an existing comment, forming a thread
Resolve comment Comment bubble or comments pane Marks a handled comment as "Resolved"; the comment stays in the document
Reopen comment Comment bubble Restores a resolved comment to the unresolved state
Edit comment Comment bubble Changes the comment text; with commentAuthorOnly enabled, users can only edit their own comments
Remove comments Review → Remove Comments Removes the current, all, "my" comments
Show all comments Review → Show All Comments Opens the comments pane to review and manage comments in one place
Restrict Editing → Comment Review → Restrict Editing Protects the document and allows only comments to be inserted

The "Remove Comments" drop-down menu provides four options: Remove Current Comments, Remove All Comments (regardless of author), Remove My Comments (only those created by the current user), and Remove My Current Comments. Removing a comment deletes only the comment itself. It does not modify the body text or affect other comments anchored at the same location.

Configure Comment Capabilities

Commenting is switched on or off by canComment in editorAttrs. The pane state on open and the author's editing scope are controlled by the switches under user.customization.public.common.

Expand the Comments Pane on Open

openAllComments controls whether the comments pane expands automatically when a document opens; the default is false. Setting it to true is equivalent to clicking "Show All Comments" right after the document opens, which suits review workflows centered on comments.

user: {
  customization: {
    public: {
      common: {
        openAllComments: true // expands the comments pane when the document opens
      }
    }
  }
}

Expand the comments pane on open

Only Authors Can Edit Their Comments

With commentAuthorOnly enabled, users can edit or delete only the comments and replies they created themselves. Comments from other authors can still be viewed, replied to, or resolved, which suits scenarios that need to preserve the original comment record.

user: {
  customization: {
    public: {
      common: {
        commentAuthorOnly: true // only the author can edit their own comments
      }
    }
  }
}

Only authors can edit their comments

Disable Comments

canComment controls whether commenting is allowed; the default is true. When set to false, the comment button group on the Review tab is hidden. Existing comments in the document remain visible but are read-only. Body editing is unaffected.

editorAttrs: {
  canComment: false
}

Note

canComment affects comments only; it does not change body editing or track changes. If the entire document must be read-only, use editorMode: 'view'.

Disable comments

Control Comment-Related Buttons

canComment only switches the commenting capability as a whole. If you want to hide only some buttons (for example, remove the "New Comment" entry while keeping viewing and navigation), configure user.customization.public.common.btnPermissions.docBtnPermissions. Removed buttons and their corresponding shortcuts are disabled as well:

user: {
  customization: {
    public: {
      common: {
        btnPermissions: {
          docBtnPermissions: [
            { modular: 'Toolbar', subModule: ['btnInsertComments'] }
          ]
        }
      }
    }
  }
}

Hide comment-related buttons

For more about button permission configuration, see the documentation on customizing the toolbar menu.

FAQ

The New Comment button is unavailable or grayed out

Common causes:

  1. No text is selected. A comment must be anchored to selected content.
  2. The cursor is inside a chart, shape, or a content control that does not support comments (such as a check box, picture, or drop-down list).

Comment authors appear as "Guest" or are all identical

Comment authors come from user.name in the current session, and the user identity comes from user.id. Pass a unique, stable id and the correct display name for each user. If no display name is provided, the author appears as "Guest"; if several users share a fixed account, all their comments show the same author.

Spire.OfficeJS supports four document types—Word, Excel, PowerPoint, and PDF. The first three can be opened and edited, while PDF is preview-only. For new documents and long-term storage, use DOCX, XLSX, and PPTX, for interoperability with WPS Office, use WPS, ET, and DPS, for external distribution and archiving, use PDF.

Supported Formats

Document Type Editor Module Supported Operations Formats
Word documents spiredocument Open and edit DOCX, DOCM, DOC, DOTX, DOTM, DOT, ODT, FODT, OTT, TXT, WPS, WPT
Excel spreadsheets spirespreadsheet Open and edit XLSX, XLSM, XLS, XLTX, XLTM, XLT, CSV, ET, ETT
PowerPoint presentations spirepresentation Open and edit PPTX, PPTM, PPT, PPSX, PPSM, PPS, POTX, POTM, POT, DPS, DPT
PDF documents spiredocument Preview only PDF, XPS
  • Legacy formats (DOC, XLS, PPT) can be opened and edited, saving them as DOCX, XLSX, and PPTX is recommended.
  • RTF, HTML, HTM, and MHT are not in the Word open list and must be converted to DOCX first.
  • Missing fonts used by a document cause changes in line breaks and pagination. See Font Management for configuration.
  • PDF is preview-only, no editing entry is provided.

Saving and Exporting

Saving usually keeps the original format. File data can be passed to your business system through fileAttrs.callbackUrl or editorAttrs.events.onSave. Downloads are available from “File → Download as…”. The table below lists the formats available in that menu; actual options may vary by version or runtime mode:

Document Type Download Formats
Word DOCX, DOC, DOCM, DOTX, DOTM, DOT, PDF, RTF, TXT, HTML, XPS, EPUB, WordXML (Word 2003 XML)
Excel XLSX, XLS, XLSM, XLSB, XLTX, XLTM, XLT, CSV, ODS, ET, ETT, PDF, XPS
PowerPoint PPTX, PPT, PPTM, PPSX, PPS, POTX, POTM, DPS, DPT, PDF, XPS, PS (PostScript)
PDF Downloads the original file as-is, format conversion is not available

When called through downloadAs, the supported range is narrower than the table above. See Conversion and Download for accepted values and examples.

In WebAssembly (serverless) mode, downloads are processed by the engine in the browser, so no separate conversion service is required. Cross-format exports reflow the document, so special fonts and complex layouts may render differently, check each page after exporting.

Page 2 of 371
page 2