- Pagina principală pentru dezvoltatori
- Încorporarea editorilor
- Automation API reference
Automation API reference
Every method of the object model, the plugin runtime and the macro scope, with its parameters and results, generated from mroffice-embed 1.6.0's TypeScript types.
Această pagină nu este încă tradusă în limba dvs.; este afișată în engleză.
editor.document
Any kind of file.
getInfo(): Promise<DocumentInfo>
export(format?: string): Promise<ExportedFile>
save(): Promise<SavedFile>
batch(calls: readonly { method: AutomationMethod; params?: Record<string, unknown> }[]): Promise<readonly unknown[]>
undo(): Promise<{ done: boolean }>
redo(): Promise<{ done: boolean }>| Member | What it does |
|---|---|
getInfo | — |
export | The document as a file (File > Export): what is typed is stored first. Formats by kind: EMBED_EXPORT_FORMATS (default: the file's own; a code file's own format is written in its own encoding and line endings). |
save | Save to your file now (as requestSave). |
batch | Run several calls as one Undo step (as ONLYOFFICE's callCommand): each is checked as if called alone; the first that fails ends the batch (its error names the call's `index`). Resolves with each call's result. |
undo | Edit > Undo / Redo (Word): resolves with whether there was a step. |
redo | — |
editor.events
Automation events (embed.js `on()` subscribes for you).
subscribe(events: readonly AutomationEventName[]): Promise<{ events: readonly AutomationEventName[] }>
unsubscribe(events: readonly AutomationEventName[]): Promise<{ events: readonly AutomationEventName[] }>| Member | What it does |
|---|---|
subscribe | — |
unsubscribe | — |
editor.word
A Word document (.docx, .doc, .odt, .rtf …).
getText(): Promise<string>
getHtml(options?: { selection?: boolean }): Promise<{ html: string; selection: boolean }>
getContent(): Promise<readonly WordBlock[]>
getSelection(): Promise<{ text: string; isEmpty: boolean; blockId: string | null }>
setSelection(target: | { readonly text: string; readonly occurrence?: number; readonly matchCase?: boolean } | { readonly all: true } | Exclude<WordLocation, string>): Promise<{ text: string }>
insertText(text: string, options?: WordInsertOptions): Promise<void>
insertHtml(html: string, options?: WordInsertOptions): Promise<void>
insertMarkdown(markdown: string, options?: WordInsertOptions): Promise<void>
replaceText(find: string, replace: string, options?: { matchCase?: boolean; wholeWord?: boolean }): Promise<{ count: number }>
insertTable(rows: readonly (readonly (string | number | null)[])[], options?: WordInsertOptions & { header?: boolean }): Promise<{ rows: number; columns: number }>
addComment(text: string, options?: { anchorText?: string; occurrence?: number; matchCase?: boolean }): Promise<{ anchoredTo: string }>
getTrackedChanges(): Promise<readonly WordTrackedChange[]>
acceptTrackedChanges(index?: number): Promise<{ count: number }>
rejectTrackedChanges(index?: number): Promise<{ count: number }>
setTrackChanges(on: boolean): Promise<{ on: boolean }>
getProperties(): Promise<Record<string, string>>
setProperties(properties: Partial<Record<"title" | "subject" | "author" | "company" | "category" | "keywords" | "abstract" | "publishDate" | "companyAddress" | "companyPhone" | "companyFax" | "companyEmail", string>>): Promise<Record<string, string>>
getBookmarks(): Promise<readonly { name: string }[]>
getContentControls(): Promise<readonly WordContentControlInfo[]>
search(text: string, options?: { matchCase?: boolean; wholeWord?: boolean; limit?: number }): Promise<readonly WordSearchResult[]>
getParagraphs(options?: { from?: number; count?: number }): Promise<{ paragraphs: readonly WordParagraphInfo[]; total: number }>
insertParagraph(text: string, options?: { location?: WordLocation; style?: string }): Promise<{ id: string | null }>
setParagraphFormat(target: WordTarget, format: WordParagraphFormat): Promise<{ count: number }>
deleteBlock(blockId: string): Promise<{ deleted: boolean }>
getRuns(blockId: string): Promise<readonly WordRunInfo[]>
setTextFormat(target: WordTarget, format: WordTextFormat): Promise<{ count: number }>
insertBreak(type: WordBreakType, options?: { location?: WordLocation }): Promise<void>
getTables(): Promise<readonly WordTableInfo[]>
setTableCells(tableId: string, values: readonly (readonly (string | number | null)[])[], options?: { row?: number; column?: number }): Promise<{ rowCount: number; columnCount: number }>
editTable(tableId: string, action: WordTableAction, options?: { row?: number; column?: number }): Promise<{ rowCount: number; columnCount: number }>
getStyles(): Promise<readonly WordStyleInfo[]>
insertContentControl(options?: { target?: WordTarget; type?: WordContentControlType; tag?: string; title?: string; text?: string }): Promise<{ tag: string; title: string }>
removeContentControl(control: { tag?: string; title?: string }, options?: { keepContents?: boolean }): Promise<{ removed: number }>
addBookmark(name: string, target?: WordTarget): Promise<{ name: string }>
deleteBookmark(name: string): Promise<{ deleted: boolean }>
getComments(): Promise<readonly WordCommentInfo[]>
replyToComment(commentId: string, text: string): Promise<{ id: string }>
resolveComment(commentId: string, resolved?: boolean): Promise<{ resolved: boolean }>
deleteComment(commentId: string): Promise<{ deleted: boolean }>
getSections(): Promise<readonly WordSectionInfo[]>
setPageSetup(setup: WordPageSetup, options?: { section?: number }): Promise<readonly WordSectionInfo[]>
setHeaderFooter(kind: "header" | "footer", text: string, options?: { section?: number; type?: "primary" | "firstPage" | "evenPages" }): Promise<void>
insertImage(src: string, options?: { alt?: string; width?: number; height?: number; location?: WordLocation }): Promise<{ id: string | null }>
getImages(): Promise<readonly WordImageInfo[]>| Member | What it does |
|---|---|
getText | — |
getHtml | The selection (or, with nothing selected or `selection: false`, the whole document) as HTML, as the editor's copy writes it. |
getContent | The body's paragraphs and tables, in order, with their block ids. |
getSelection | — |
setSelection | Select the `occurrence`-th match of `text`, a bookmark, a content control, a block, or `{ all: true }`. |
insertText | — |
insertHtml | HTML read by the editor's own paste: headings, lists, tables, links, bold/italic …; what it has no place for (scripts, styles) is dropped. |
insertMarkdown | — |
replaceText | Replace All (Word's): every occurrence, its formatting kept; tracked when Track Changes is on. |
insertTable | — |
addComment | A comment on the selection, or on the `occurrence`-th match of `anchorText`. |
getTrackedChanges | — |
acceptTrackedChanges | One change by its index (getTrackedChanges), or all of them. |
rejectTrackedChanges | — |
setTrackChanges | Review > Track Changes, for everyone. |
getProperties | — |
setProperties | — |
getBookmarks | — |
getContentControls | — |
search | Every match of `text` (Office.js body.search), with the block it is in and its occurrence number, which a WordTarget takes. |
getParagraphs | The paragraphs (table cells' included) with their style, alignment, list, indents and spacing; `from`/`count` page through a long document. |
insertParagraph | A new paragraph (Office.js insertParagraph): at "start" or "end", or before/after a block ({ blockId, position }); in `style` when given. Each line of `text` is one paragraph. Resolves with the new block's id. |
setParagraphFormat | Style, alignment, indents, spacing and lists of the paragraphs `target` touches. |
deleteBlock | Delete a paragraph, a table or another block by its id. |
getRuns | A paragraph's runs: its text in pieces of one formatting each. |
setTextFormat | Bold, italic, font, size, colour, highlight, link… of the text `target` names. |
insertBreak | A page, line, column or section break at the selection (or `location`). |
getTables | — |
setTableCells | Write cell text into a table (by its id from getTables), from `row`, `column` (0-based). |
editTable | Layout > Rows & Columns: add or delete a row or column next to `row`/`column`, or delete the table. |
getStyles | The styles the document defines (Home > Styles), paragraph and character. |
insertContentControl | Wrap `target` (default: the selection) in a content control (Developer > Controls). |
removeContentControl | Remove a content control, keeping its contents unless `keepContents` is false. |
addBookmark | Insert > Bookmark over the text `target` names. |
deleteBookmark | — |
getComments | The comments with their replies, resolution and the words they are on. |
replyToComment | — |
resolveComment | — |
deleteComment | — |
getSections | Each section's page setup and its header and footer text. |
setPageSetup | Layout > Page Setup: orientation, size and margins (points), for one section or (by default) the whole document. |
setHeaderFooter | Insert > Header / Footer text of a section (default: every section). |
insertImage | A picture from a data: URL or an https URL, at the selection (or `location`); points. |
getImages | — |
editor.excel
An Excel workbook (.xlsx, .xls, .ods, .csv …).
getSheets(): Promise<readonly { id: string; name: string; index: number; active: boolean; hidden: boolean }[]>
addSheet(name?: string): Promise<{ name: string | null; index: number }>
getUsedRange(sheet?: string): Promise<{ address: string | null; rowCount: number; columnCount: number }>
getRange(address: string): Promise<ExcelRangeResult>
setValues(address: string, values: readonly (readonly (string | number | boolean | null)[])[], options?: { asTyped?: boolean }): Promise<ExcelRangeResult>
setFormulas(address: string, formulas: readonly (readonly (string | null)[])[]): Promise<ExcelRangeResult>
getSelection(): Promise<ExcelSelectionResult>
renameSheet(sheet: string, name: string): Promise<{ name: string }>
deleteSheet(sheet: string): Promise<{ deleted: boolean }>
activateSheet(sheet: string): Promise<{ name: string }>
setSheetVisibility(sheet: string, hidden: boolean): Promise<{ hidden: boolean }>
clear(address: string, options?: { applyTo?: "all" | "contents" | "formats" }): Promise<{ address: string }>
select(address: string): Promise<ExcelSelectionResult>
find(text: string, options?: { sheet?: string; matchCase?: boolean; wholeCell?: boolean; limit?: number }): Promise<readonly ExcelFindResult[]>
getFormat(address: string): Promise<{ address: string; formats: readonly (readonly ExcelCellFormat[])[] }>
setFormat(address: string, format: ExcelCellFormat): Promise<{ address: string }>
insertRows(address: string): Promise<{ address: string }>
deleteRows(address: string): Promise<{ address: string }>
insertColumns(address: string): Promise<{ address: string }>
deleteColumns(address: string): Promise<{ address: string }>
setColumnWidth(address: string, width: number | null): Promise<{ address: string }>
setRowHeight(address: string, height: number | null): Promise<{ address: string }>
merge(address: string): Promise<{ address: string }>
unmerge(address: string): Promise<{ address: string }>
freezePanes(rows: number, columns: number, options?: { sheet?: string }): Promise<{ rows: number; columns: number }>
sort(address: string, keys: readonly { column: string; ascending?: boolean }[], options?: { hasHeaders?: boolean }): Promise<{ address: string }>
setAutoFilter(address: string | null, criteria?: readonly { column: string; values: readonly string[] }[], options?: { sheet?: string }): Promise<{ address: string | null }>
setHyperlink(address: string, url: string | null): Promise<{ address: string }>
getTables(options?: { sheet?: string }): Promise<readonly ExcelTableInfo[]>
addTable(address: string, options?: { name?: string; hasHeaders?: boolean; style?: string }): Promise<ExcelTableInfo>
deleteTable(name: string): Promise<{ deleted: boolean }>
getCharts(options?: { sheet?: string }): Promise<readonly ExcelChartInfo[]>
addChart(type: ExcelChartType, source: string, options?: { title?: string; seriesBy?: "columns" | "rows" }): Promise<{ id: string }>
deleteChart(chartId: string): Promise<{ deleted: boolean }>
getNamedRanges(): Promise<readonly ExcelNamedRangeInfo[]>
addNamedRange(name: string, refersTo: string, options?: { comment?: string }): Promise<ExcelNamedRangeInfo>
deleteNamedRange(name: string): Promise<{ deleted: boolean }>
getComments(options?: { sheet?: string }): Promise<readonly ExcelCommentInfo[]>
addComment(address: string, text: string): Promise<ExcelCommentInfo>
deleteComment(address: string): Promise<{ deleted: boolean }>| Member | What it does |
|---|---|
getSheets | — |
addSheet | A new sheet after the last one (named like Excel's next SheetN). |
getUsedRange | — |
getRange | "A1", "B2:D9", "Sheet2!A1:C3" (the open sheet when none is named). |
setValues | Values typed in from the range's top-left cell, row by row ("=…" is a formula; "50%", "$1,000", dates are read as Excel reads them typed unless asTyped is false). Resolves with the range as written. |
setFormulas | — |
getSelection | What the person has selected: the open sheet, the selected range and its active cell. |
renameSheet | — |
deleteSheet | — |
activateSheet | Show a sheet (its tab). |
setSheetVisibility | — |
clear | Home > Clear: everything (default), the contents only or the formats only. |
select | Select a range (Office.js Range.select()); its sheet is shown. |
find | Cells whose value contains `text` (Home > Find), on one sheet or all. |
getFormat | Each cell's format, row by row. |
setFormat | Number format, font, fill, alignment, wrap and borders of every cell of the range. |
insertRows | Insert whole rows ("3:5" inserts three rows above row 3) or columns ("C:D"). |
deleteRows | — |
insertColumns | — |
deleteColumns | — |
setColumnWidth | Column width ("B:D") or row height ("2:4") in points; null restores the default. |
setRowHeight | — |
merge | — |
unmerge | — |
freezePanes | View > Freeze Panes: the top `rows` and left `columns` (0, 0 unfreezes). |
sort | Data > Sort: by one or more columns ("B", or its letter in the sheet). |
setAutoFilter | Data > Filter on a range, showing only rows whose `column` value is one of `values`; `null` turns the filter off. |
setHyperlink | A hyperlink on a cell (http, https, mailto), or null to remove it. |
getTables | — |
addTable | Insert > Table over a range. |
deleteTable | — |
getCharts | — |
addChart | Insert > Chart from a range's data, placed beside it. |
deleteChart | — |
getNamedRanges | Formulas > Name Manager. |
addNamedRange | — |
deleteNamedRange | — |
getComments | — |
addComment | — |
deleteComment | — |
editor.powerpoint
A presentation (.pptx, .ppt, .odp …).
getSlides(): Promise<{ slides: readonly PowerPointSlideInfo[]; activeIndex: number }>
addSlide(options?: { title?: string; body?: string; layout?: string; index?: number }): Promise<{ index: number; id: string }>
replaceText(find: string, replace: string, options?: { matchCase?: boolean; wholeWord?: boolean }): Promise<{ count: number }>
goToSlide(index: number): Promise<{ index: number }>
setShapeText(slide: number | string, shapeId: string, text: string): Promise<{ index: number; id: string }>
getSelection(): Promise<{ slideIndex: number; slideId: string; shapeIds: readonly string[] }>
deleteSlide(slide: number | string): Promise<{ count: number }>
duplicateSlide(slide: number | string): Promise<{ index: number; id: string }>
moveSlide(slide: number | string, to: number): Promise<{ index: number }>
setSlideHidden(slide: number | string, hidden: boolean): Promise<{ hidden: boolean }>
getLayouts(): Promise<readonly PowerPointLayoutInfo[]>
getShapes(slide: number | string): Promise<readonly PowerPointShapeDetail[]>
addTextBox(slide: number | string, text: string, options?: PowerPointPlacement & { format?: PowerPointShapeFormat }): Promise<{ id: string }>
addShape(slide: number | string, shape: PowerPointGeometricShape, options?: PowerPointPlacement & { text?: string; format?: PowerPointShapeFormat }): Promise<{ id: string }>
addImage(slide: number | string, src: string, options?: PowerPointPlacement & { alt?: string }): Promise<{ id: string }>
addTable(slide: number | string, values: readonly (readonly (string | number | null)[])[], options?: PowerPointPlacement): Promise<{ id: string }>
setTableCell(slide: number | string, shapeId: string, row: number, column: number, text: string): Promise<void>
setShapeGeometry(slide: number | string, shapeId: string, geometry: PowerPointPlacement & { rotation?: number }): Promise<PowerPointShapeDetail>
setShapeFormat(slide: number | string, shapeId: string, format: PowerPointShapeFormat): Promise<void>
deleteShape(slide: number | string, shapeId: string): Promise<{ deleted: boolean }>
getNotes(slide: number | string): Promise<string>
setNotes(slide: number | string, text: string): Promise<void>| Member | What it does |
|---|---|
getSlides | — |
addSlide | A new slide at `index` (default: the end), its layout's title and body filled. |
replaceText | — |
goToSlide | — |
setShapeText | Type `text` into one shape (its id from getSlides' `shapes`), each line one paragraph in the shape's own first paragraph's format. |
getSelection | The slide shown and the shapes selected on it. |
deleteSlide | A slide by its index or id. |
duplicateSlide | — |
moveSlide | Move a slide to index `to`. |
setSlideHidden | — |
getLayouts | The layouts New Slide offers (their ids are what addSlide's `layout` takes). |
getShapes | Every shape of a slide with its place and size (points). |
addTextBox | — |
addShape | — |
addImage | A picture from a data: URL or an https URL. |
addTable | — |
setTableCell | — |
setShapeGeometry | Move, resize or turn a shape (points, degrees). |
setShapeFormat | — |
deleteShape | — |
getNotes | A slide's speaker notes. |
setNotes | — |
editor.pdf
A PDF.
goToPage(page: number): Promise<{ page: number }>
search(text: string, options?: { limit?: number }): Promise<readonly { page: number; snippet: string; index: number }[]>
addHighlight(text: string, options?: { page?: number; occurrence?: number; style?: "highlight" | "underline" | "strikethrough" | "squiggly" }): Promise<{ page: number }>
addComment(text: string, options?: { page?: number }): Promise<{ page: number }>
getPages(): Promise<{ pages: readonly PdfPageInfo[]; currentPage: number }>
getPageText(page: number): Promise<string>
getAnnotations(options?: { page?: number }): Promise<readonly PdfAnnotationInfo[]>
getFormFields(): Promise<readonly PdfFormFieldInfo[]>
setFormFieldValue(name: string, value: string | boolean | readonly string[]): Promise<{ name: string }>
rotatePage(page: number, degrees: 0 | 90 | 180 | 270): Promise<{ page: number; rotation: number }>| Member | What it does |
|---|---|
goToPage | — |
search | — |
addHighlight | The ribbon's Highlight (or underline, strikethrough, squiggly) over the `occurrence`-th match of `text` (on `page` when given). |
addComment | A sticky note on `page` (default: the page shown). |
getPages | The pages (1-based) with their size in points and rotation, and the page shown. |
getPageText | A page's text, as its text layer reads. |
getAnnotations | Highlights, notes, ink, shapes, stamps… (of one page, or all). |
getFormFields | The form's fields with their values (Acrobat's Prepare Form names). |
setFormFieldValue | Fill in a field: text, true/false for a check box, an option's value for a radio group or list. Runs in a fillForms session too. |
rotatePage | Set a page's turn: 90, 180 or 270 degrees clockwise from how the file has it (0 restores it). |
editor.code
A source file in the Code editor.
getText(): Promise<{ text: string; language: string; lineCount: number }>
getSelection(): Promise<{ text: string; isEmpty: boolean; from: CodePosition | null; to: CodePosition | null }>
setSelection(from: { line: number; column?: number }, to?: { line: number; column?: number }): Promise<{ text: string }>
setText(text: string): Promise<{ length: number }>
insertText(text: string, options?: { location?: CodeLocation }): Promise<{ at: CodePosition; end: CodePosition }>| Member | What it does |
|---|---|
getText | — |
getSelection | — |
setSelection | Select from one place to another (1-based lines and columns), or put the cursor at `from`. |
setText | Replace the whole file. |
insertText | Insert at the selection (replacing it; default), the start, the end, or a line and column. |
editor.ink
A handwriting document (.mrink).
getStrokes(): Promise<{ count: number; strokes: readonly InkStrokeInfo[] }>
clear(): Promise<{ removed: number }>| Member | What it does |
|---|---|
getStrokes | The pen, pencil and highlighter strokes, in document order. |
clear | Erase every stroke (one step: Undo brings them back). |
MROffice.plugin
The runtime of a plugin page: the whole object model above, plus these.
readonly ready: Promise<PluginInfo>
on(event: AutomationEventName, listener: (data: unknown) => void): () => void
onCommand(id: string, listener: (event: PluginCommandEvent) => void | Promise<void>): () => void
onInput(listener: (event: { text: string }) => void): () => void
readonly ui: PluginUi
tr(text: string): string| Member | What it does |
|---|---|
ready | — |
on | Hear an automation event ("selectionChange", "contentChange", "documentReady"). |
onCommand | Run `listener` when the person chooses one of the plugin's commands (by id; "*" hears every command no listener of its own takes). |
onInput | As the person types (manifest `inputHelper: true`): the word before the caret, to offer suggestions for with `ui.setInputHelper`. |
ui | — |
tr | A string in the editor's language, from the manifest's `translations`. |
MROffice.plugin.ui
A plugin's part of the editor's interface.
closePanel(): void
openPanel(): void
notify(text: string, options?: { kind?: "info" | "success" | "error" }): void
setInputHelper(items: readonly PluginInputHelperItem[]): void
setContextMenu(items: readonly { id: string; label: string; when?: "always" | "selection" }[]): void
setRibbon(items: readonly { id: string; label: string }[]): void| Member | What it does |
|---|---|
closePanel | Close the plugin's panel (a background plugin goes on running). |
openPanel | Show the panel (a background plugin's, too, when it has one). |
notify | A short notice in the editor. |
setInputHelper | Offer items under the caret as the person types (ONLYOFFICE's input helper); [] hides it. The person's choice arrives as a command whose source is "inputHelper". |
setContextMenu | Items of the editor's right-click menu this plugin adds now (replacing its last; `when: "selection"` shows one only with something selected). |
setRibbon | Buttons this plugin adds to the editor's Plugins tab now (replacing its last). |
Methods by kind of file
What each method runs on, and whether it writes (a writing method is refused in a view session; comments also run in a comment session that may comment, fills in a fill-in session).
| Method | Files | Writes |
|---|---|---|
getCapabilities | docx, xlsx, pptx, pdf, code, ink | no |
document.getInfo | docx, xlsx, pptx, pdf, code, ink | no |
document.export | docx, xlsx, pptx, pdf, code, ink | no |
document.save | docx, xlsx, pptx, pdf, code, ink | yes (saves) |
document.batch | docx, xlsx, pptx, pdf, code, ink | no |
document.undo | docx | yes |
document.redo | docx | yes |
events.subscribe | docx, xlsx, pptx, pdf, code, ink | no |
events.unsubscribe | docx, xlsx, pptx, pdf, code, ink | no |
word.getText | docx | no |
word.getContent | docx | no |
word.getHtml | docx | no |
word.getSelection | docx | no |
word.setSelection | docx | no |
word.insertText | docx | yes |
word.insertHtml | docx | yes |
word.insertMarkdown | docx | yes |
word.replaceText | docx | yes |
word.search | docx | no |
word.getParagraphs | docx | no |
word.insertParagraph | docx | yes |
word.setParagraphFormat | docx | yes |
word.deleteBlock | docx | yes |
word.getRuns | docx | no |
word.setTextFormat | docx | yes |
word.insertBreak | docx | yes |
word.insertTable | docx | yes |
word.getTables | docx | no |
word.setTableCells | docx | yes |
word.editTable | docx | yes |
word.getStyles | docx | no |
word.getContentControls | docx | no |
word.insertContentControl | docx | yes |
word.removeContentControl | docx | yes |
word.getBookmarks | docx | no |
word.addBookmark | docx | yes |
word.deleteBookmark | docx | yes |
word.addComment | docx | yes (comments) |
word.getComments | docx | no |
word.replyToComment | docx | yes (comments) |
word.resolveComment | docx | yes (comments) |
word.deleteComment | docx | yes (comments) |
word.getTrackedChanges | docx | no |
word.acceptTrackedChanges | docx | yes (reviews) |
word.rejectTrackedChanges | docx | yes (reviews) |
word.setTrackChanges | docx | yes |
word.getSections | docx | no |
word.setPageSetup | docx | yes |
word.setHeaderFooter | docx | yes |
word.insertImage | docx | yes |
word.getImages | docx | no |
word.getProperties | docx | no |
word.setProperties | docx | yes |
excel.getSheets | xlsx | no |
excel.addSheet | xlsx | yes |
excel.renameSheet | xlsx | yes |
excel.deleteSheet | xlsx | yes |
excel.activateSheet | xlsx | no |
excel.setSheetVisibility | xlsx | yes |
excel.getUsedRange | xlsx | no |
excel.getRange | xlsx | no |
excel.setValues | xlsx | yes |
excel.setFormulas | xlsx | yes |
excel.clear | xlsx | yes |
excel.getSelection | xlsx | no |
excel.select | xlsx | no |
excel.find | xlsx | no |
excel.getFormat | xlsx | no |
excel.setFormat | xlsx | yes |
excel.insertRows | xlsx | yes |
excel.deleteRows | xlsx | yes |
excel.insertColumns | xlsx | yes |
excel.deleteColumns | xlsx | yes |
excel.setColumnWidth | xlsx | yes |
excel.setRowHeight | xlsx | yes |
excel.merge | xlsx | yes |
excel.unmerge | xlsx | yes |
excel.freezePanes | xlsx | yes |
excel.sort | xlsx | yes |
excel.setAutoFilter | xlsx | yes |
excel.setHyperlink | xlsx | yes |
excel.getTables | xlsx | no |
excel.addTable | xlsx | yes |
excel.deleteTable | xlsx | yes |
excel.getCharts | xlsx | no |
excel.addChart | xlsx | yes |
excel.deleteChart | xlsx | yes |
excel.getNamedRanges | xlsx | no |
excel.addNamedRange | xlsx | yes |
excel.deleteNamedRange | xlsx | yes |
excel.getComments | xlsx | no |
excel.addComment | xlsx | yes (comments) |
excel.deleteComment | xlsx | yes (comments) |
powerpoint.getSlides | pptx | no |
powerpoint.getSelection | pptx | no |
powerpoint.goToSlide | pptx | no |
powerpoint.addSlide | pptx | yes |
powerpoint.deleteSlide | pptx | yes |
powerpoint.duplicateSlide | pptx | yes |
powerpoint.moveSlide | pptx | yes |
powerpoint.setSlideHidden | pptx | yes |
powerpoint.getLayouts | pptx | no |
powerpoint.replaceText | pptx | yes |
powerpoint.getShapes | pptx | no |
powerpoint.setShapeText | pptx | yes |
powerpoint.addTextBox | pptx | yes |
powerpoint.addShape | pptx | yes |
powerpoint.addImage | pptx | yes |
powerpoint.addTable | pptx | yes |
powerpoint.setTableCell | pptx | yes |
powerpoint.setShapeGeometry | pptx | yes |
powerpoint.setShapeFormat | pptx | yes |
powerpoint.deleteShape | pptx | yes |
powerpoint.getNotes | pptx | no |
powerpoint.setNotes | pptx | yes |
pdf.getPages | no | |
pdf.goToPage | no | |
pdf.getPageText | no | |
pdf.search | no | |
pdf.getAnnotations | no | |
pdf.addHighlight | yes | |
pdf.addComment | yes (comments) | |
pdf.getFormFields | no | |
pdf.setFormFieldValue | yes (fills) | |
pdf.rotatePage | yes | |
code.getText | code | no |
code.getSelection | code | no |
code.setSelection | code | no |
code.setText | code | yes |
code.insertText | code | yes |
ink.getStrokes | ink | no |
ink.clear | ink | yes |
Types
AutomationCall
export interface AutomationCall {
readonly method: AutomationMethod;
readonly params: Record<string, unknown>;
readonly apiVersion: number;
}AutomationCapabilities
What the frame says it can do (`getCapabilities()`).
export interface AutomationCapabilities {
readonly apiVersion: number;
readonly kind: AutomationFileKind | null;
readonly mode: AutomationSessionMode;
readonly methods: readonly AutomationMethod[];
readonly exportFormats: readonly string[];
readonly exportAllowed: boolean;
}AutomationContentEvent
`contentChange`'s data: the document changed (by anyone in it, Undo included); `dirty` says whether edits are still on their way to MR Office.
export interface AutomationContentEvent {
readonly kind: AutomationFileKind;
readonly dirty: boolean;
}AutomationErrorCode
export type AutomationErrorCode = (typeof EMBED_AUTOMATION_ERRORS)[number];AutomationEventName
export type AutomationEventName = (typeof EMBED_AUTOMATION_EVENTS)[number];AutomationFileKind
export type AutomationFileKind = "docx" | "xlsx" | "pptx" | "pdf" | "code" | "ink";AutomationMethod
export type AutomationMethod = keyof typeof EMBED_AUTOMATION_METHODS;AutomationMethodSpec
export interface AutomationMethodSpec {
readonly kinds: readonly AutomationFileKind[];
readonly writes: boolean;
readonly comments?: true;
readonly reviews?: true;
readonly exports?: true;
readonly saves?: true;
readonly fills?: true;
}AutomationPermissions
What the token's permissions say, as far as the Automation API reads them.
export interface AutomationPermissions {
readonly comment?: boolean;
readonly acceptRejectChanges?: boolean;
readonly download?: boolean;
}AutomationSelectionEvent
`selectionChange`'s data, by kind of file.
export type AutomationSelectionEvent =
| { readonly kind: "docx"; readonly text: string; readonly isEmpty: boolean; readonly blockId: string | null }
| { readonly kind: "xlsx"; readonly sheet: string; readonly address: string; readonly activeCell: string }
| { readonly kind: "pptx"; readonly slideIndex: number; readonly slideId: string; readonly shapeIds: readonly string[] }
| { readonly kind: "pdf"; readonly page: number }
| { readonly kind: "code"; readonly from: CodePosition | null; readonly to: CodePosition | null }
| { readonly kind: "ink" };AutomationSessionMode
The session's mode (the token's, as the frame opened it).
export type AutomationSessionMode = "edit" | "view" | "comment" | "review" | "fillForms";CodeLocation
Where code.insertText puts its text: the selection (replacing it), the start or end of the file, or a 1-based line and column.
export type CodeLocation = "selection" | "start" | "end" | { readonly line: number; readonly column?: number };CodePosition
A place in a code file: 1-based line and column, and the offset from the start.
export interface CodePosition {
readonly line: number;
readonly column: number;
readonly offset: number;
}DocumentInfo
export interface DocumentInfo {
readonly key: string;
readonly name: string;
readonly kind: "docx" | "xlsx" | "pptx" | "pdf" | "code" | "ink";
readonly mode: "edit" | "view" | "comment" | "review" | "fillForms";
readonly version: number;
readonly partnerVersion: string | null;
readonly dirty: boolean;
}ExcelCellFormat
Number formats, fonts, fill, alignment and borders of cells (Office.js Range.format / numberFormat; ONLYOFFICE ApiRange.Set…). Sizes in points.
export interface ExcelCellFormat {
readonly numberFormat?: string | null;
readonly bold?: boolean;
readonly italic?: boolean;
readonly underline?: boolean;
readonly strikethrough?: boolean;
readonly fontName?: string | null;
readonly fontSize?: number | null;
readonly fontColor?: string | null;
readonly fill?: string | null;
readonly horizontalAlignment?: "left" | "center" | "right" | null;
readonly verticalAlignment?: "top" | "middle" | "bottom" | null;
readonly wrapText?: boolean;
readonly borders?: boolean | { readonly top?: boolean; readonly right?: boolean; readonly bottom?: boolean; readonly left?: boolean };
}ExcelChartInfo
export interface ExcelChartInfo {
readonly id: string;
readonly sheet: string;
readonly type: string;
readonly title: string | null;
readonly source: string | null;
}ExcelChartType
export type ExcelChartType = "column" | "bar" | "line" | "pie" | "area" | "scatter" | "doughnut";ExcelCommentInfo
export interface ExcelCommentInfo {
readonly address: string;
readonly author: string | null;
readonly text: string;
}ExcelFindResult
export interface ExcelFindResult {
readonly address: string;
readonly value: string | number | boolean;
}ExcelNamedRangeInfo
export interface ExcelNamedRangeInfo {
readonly name: string;
readonly refersTo: string;
readonly scope: string | null;
readonly comment: string | null;
}ExcelRangeResult
export interface ExcelRangeResult {
readonly address: string;
readonly values: readonly (readonly (string | number | boolean)[])[];
readonly formulas: readonly (readonly string[])[];
}ExcelSelectionResult
What the person has selected in a workbook (`excel.getSelection`).
export interface ExcelSelectionResult {
readonly sheet: string;
readonly address: string;
readonly activeCell: string;
}ExcelTableInfo
export interface ExcelTableInfo {
readonly id: string;
readonly name: string;
readonly sheet: string;
readonly address: string;
readonly hasHeaders: boolean;
readonly style: string | null;
}ExportedFile
export interface ExportedFile {
readonly name: string;
readonly mimeType: string;
readonly size: number;
readonly blob: Blob;
readonly layout?: "editor" | "fallback";
readonly layoutReasons?: readonly string[];
}InkStrokeInfo
One pen, pencil or highlighter stroke of a handwriting document (`ink.getStrokes`).
export interface InkStrokeInfo {
readonly index: number;
readonly tool: string;
readonly color: string;
readonly widthPt: number;
}PdfAnnotationInfo
export interface PdfAnnotationInfo {
readonly id: string;
readonly type: "highlight" | "underline" | "strikethrough" | "squiggly" | "note" | "ink" | "shape" | "stamp" | "signature" | "freeText" | "redaction";
readonly page: number;
readonly text: string;
readonly color: string | null;
readonly author: string | null;
readonly createdAt: string | null;
}PdfFormFieldInfo
export interface PdfFormFieldInfo {
readonly name: string;
readonly type: "text" | "checkbox" | "radio" | "dropdown" | "list" | "signature" | "button";
readonly value: string | boolean | readonly string[] | null;
readonly page: number | null;
readonly readOnly: boolean;
readonly required: boolean;
readonly options?: readonly string[];
}PdfPageInfo
export interface PdfPageInfo {
readonly page: number;
readonly width: number;
readonly height: number;
readonly rotation: 0 | 90 | 180 | 270;
}PluginCommandEvent
A ribbon button, context-menu item or input-helper item the person chose.
export interface PluginCommandEvent {
readonly id: string;
readonly source: string;
readonly selectionText?: string;
}PluginInfo
What the editor tells a plugin when it connects.
export interface PluginInfo {
readonly pluginId: string;
readonly version: string;
readonly kind: string;
readonly mode: string;
readonly locale: string;
readonly theme: "light" | "dark";
readonly surface: "panel" | "background";
readonly permissions: readonly string[];
readonly options: Readonly<Record<string, unknown>>;
readonly onlyoffice?: Readonly<Record<string, unknown>>;
}PluginInputHelperItem
export interface PluginInputHelperItem {
readonly id: string;
readonly label: string;
readonly description?: string;
}PowerPointGeometricShape
export type PowerPointGeometricShape =
| "rectangle"
| "roundRectangle"
| "ellipse"
| "triangle"
| "diamond"
| "rightArrow"
| "line";PowerPointLayoutInfo
export interface PowerPointLayoutInfo {
readonly id: string;
readonly name: string;
}PowerPointPlacement
Where a new shape goes on its slide, in points (each defaulted when not given).
export interface PowerPointPlacement {
readonly left?: number;
readonly top?: number;
readonly width?: number;
readonly height?: number;
}PowerPointShapeDetail
A shape on a slide, where it is and what it holds (Office.js PowerPoint.Shape).
export interface PowerPointShapeDetail extends PowerPointShapeInfo {
readonly name: string | null;
readonly left: number;
readonly top: number;
readonly width: number;
readonly height: number;
readonly rotation: number;
readonly alt?: string | null;
}PowerPointShapeFormat
export interface PowerPointShapeFormat {
readonly fill?: string | null;
readonly lineColor?: string | null;
readonly lineWidth?: number | null;
readonly fontColor?: string | null;
readonly fontSize?: number | null;
readonly fontName?: string | null;
readonly bold?: boolean;
readonly italic?: boolean;
readonly alignment?: "left" | "center" | "right" | "justify";
}PowerPointShapeInfo
One shape of a slide that holds text (`powerpoint.getSlides`; its id is what `powerpoint.setShapeText` takes).
export interface PowerPointShapeInfo {
readonly id: string;
readonly type: string;
readonly placeholder: string | null;
readonly text: string;
}PowerPointSlideInfo
export interface PowerPointSlideInfo {
readonly index: number;
readonly id: string;
readonly title: string;
readonly text: string;
readonly hidden: boolean;
readonly shapes?: readonly PowerPointShapeInfo[];
}SavedFile
export interface SavedFile {
readonly saveId: string;
readonly unchanged: boolean;
readonly version: number | null;
readonly sha256: string | null;
readonly size: number | null;
readonly downloadUrl: string | null;
readonly downloadExpiresAt: string | null;
}WordAlignment
export type WordAlignment = "left" | "center" | "right" | "justify";WordBlock
One block of a Word document's body (`word.getContent`).
export type WordBlock =
| {
readonly type: "paragraph";
readonly id: string | null;
readonly style: string;
readonly level?: number;
readonly text: string;
}
| { readonly type: "table"; readonly id: string | null; readonly rows: readonly (readonly string[])[] }
| { readonly type: "object"; readonly id: string | null; readonly objectType: string };WordBreakType
export type WordBreakType = "page" | "line" | "column" | "sectionNextPage" | "sectionContinuous";WordCommentInfo
export interface WordCommentInfo extends WordCommentReply {
readonly resolved: boolean;
readonly anchorText: string;
readonly replies: readonly WordCommentReply[];
}WordCommentReply
export interface WordCommentReply {
readonly id: string;
readonly author: string | null;
readonly date: string | null;
readonly text: string;
}WordContentControlInfo
export interface WordContentControlInfo {
readonly tag: string;
readonly title: string;
readonly type: string;
readonly text: string;
readonly locked: boolean;
}WordContentControlType
export type WordContentControlType = "richText" | "plainText" | "checkbox" | "date" | "dropdown" | "picture";WordImageInfo
export interface WordImageInfo {
readonly id: string | null;
readonly alt: string;
readonly width: number | null;
readonly height: number | null;
}WordInsertOptions
export interface WordInsertOptions {
readonly location?: WordLocation;
}WordLocation
Where Word's insert methods put their content.
export type WordLocation =
| "selection"
| "start"
| "end"
| { readonly bookmark: string; readonly position?: "replace" | "before" | "after" }
| { readonly contentControl: { readonly tag?: string; readonly title?: string }; readonly position?: "replace" | "before" | "after" }
| { readonly blockId: string; readonly position?: "replace" | "before" | "after" };WordPageSetup
export interface WordPageSetup {
readonly orientation?: "portrait" | "landscape";
readonly pageSize?: "A3" | "A4" | "A5" | "B5" | "Letter" | "Legal" | "Tabloid" | { readonly width: number; readonly height: number };
readonly margins?: { readonly top?: number; readonly right?: number; readonly bottom?: number; readonly left?: number };
}WordParagraphFormat
Paragraph formatting (Office.js Paragraph.style/alignment/…indent/space…).
export interface WordParagraphFormat {
readonly style?: string;
readonly alignment?: WordAlignment;
readonly leftIndent?: number;
readonly rightIndent?: number;
readonly firstLineIndent?: number;
readonly spaceBefore?: number;
readonly spaceAfter?: number;
readonly lineSpacing?: number;
readonly list?: "bullet" | "number" | "none";
}WordParagraphInfo
A paragraph (Office.js Word.Paragraph; ONLYOFFICE ApiParagraph).
export interface WordParagraphInfo {
readonly id: string | null;
readonly index: number;
readonly text: string;
readonly style: string;
readonly alignment: WordAlignment;
readonly outlineLevel?: number;
readonly list: { readonly type: "bullet" | "number"; readonly level: number } | null;
readonly inTable: boolean;
readonly leftIndent: number | null;
readonly rightIndent: number | null;
readonly firstLineIndent: number | null;
readonly spaceBefore: number | null;
readonly spaceAfter: number | null;
readonly lineSpacing: number | null;
}WordRunInfo
A run of a paragraph: text of one formatting (ONLYOFFICE ApiRun).
export interface WordRunInfo extends Required<Omit<WordTextFormat, "fontName" | "fontSize" | "color" | "highlight" | "link">> {
readonly text: string;
readonly fontName: string | null;
readonly fontSize: number | null;
readonly color: string | null;
readonly highlight: string | null;
readonly link: string | null;
}WordSearchResult
export interface WordSearchResult {
readonly blockId: string | null;
readonly text: string;
readonly occurrence: number;
readonly context: string;
}WordSectionInfo
A section's page setup and its header and footer text (Office.js Word.Section).
export interface WordSectionInfo {
readonly index: number;
readonly orientation: "portrait" | "landscape";
readonly pageWidth: number;
readonly pageHeight: number;
readonly margins: { readonly top: number; readonly right: number; readonly bottom: number; readonly left: number };
readonly columns: number;
readonly headers: { readonly primary: string; readonly firstPage: string | null; readonly evenPages: string | null };
readonly footers: { readonly primary: string; readonly firstPage: string | null; readonly evenPages: string | null };
}WordStyleInfo
export interface WordStyleInfo {
readonly id: string;
readonly name: string;
readonly type: "paragraph" | "character" | "table" | "list";
readonly builtIn: boolean;
}WordTableAction
export type WordTableAction =
| "addRowBefore"
| "addRowAfter"
| "addColumnBefore"
| "addColumnAfter"
| "deleteRow"
| "deleteColumn"
| "toggleHeaderRow"
| "deleteTable";WordTableInfo
export interface WordTableInfo {
readonly id: string | null;
readonly index: number;
readonly rowCount: number;
readonly columnCount: number;
readonly values: readonly (readonly string[])[];
}WordTarget
What a Word call acts on: the selection, one block, several blocks, or the `occurrence`-th match of a text (1-based; `all: true` every match).
export type WordTarget =
| "selection"
| { readonly blockId: string }
| { readonly blockIds: readonly string[] }
| { readonly text: string; readonly occurrence?: number; readonly all?: boolean; readonly matchCase?: boolean; readonly wholeWord?: boolean };WordTextFormat
Character formatting (Office.js Word.Font, ONLYOFFICE ApiTextPr). null clears.
export interface WordTextFormat {
readonly bold?: boolean;
readonly italic?: boolean;
readonly underline?: boolean;
readonly strikethrough?: boolean;
readonly superscript?: boolean;
readonly subscript?: boolean;
readonly fontName?: string | null;
readonly fontSize?: number | null;
readonly color?: string | null;
readonly highlight?: string | null;
readonly link?: string | null;
}WordTrackedChange
export interface WordTrackedChange {
readonly index: number;
readonly kind: "insertion" | "deletion" | "formatting" | "move";
readonly author: string | null;
readonly date: string | null;
readonly text: string;
}