Try the fastest and simplest way to install ONLYOFFICE

Inserting a table with pure JavaScript (not a plugin)

Integration questions/issues

Inserting a table with pure JavaScript (not a plugin)

Postby John at O5 » Thu Dec 07, 2017 2:03 am

Greetings,

I am using Integration Edition to put OnlyOffice Word editor on my site.

I have a button that needs to inject a table into the document.

Here is the code that my button executes:

Code: Select all
var Api = new window.Asc.asc_docs_api(); // This line does not work. How can I get access to the Api for inserting content?

var oDocument = Api.GetDocument();
var oTable, oCell;
oDocument.CreateNewHistoryPoint();
oTable = Api.CreateTable(2, 2);
oTable.GetRow(0).GetCell(0).GetContent().GetElement(0).AddText("A");
oTable.GetRow(0).GetCell(1).GetContent().GetElement(0).AddText("B");
oTable.GetRow(1).GetCell(0).GetContent().GetElement(0).AddText("a1");
oTable.GetRow(1).GetCell(1).GetContent().GetElement(0).AddText("b1");
oDocument.Push(oTable);


The first line fails, so I am not able to get access to the Api.

How can I get access to the Api to inject this table?

Thanks for your help!
-John
John at O5
 
Posts: 3
Joined: Thu Dec 07, 2017 12:31 am

Re: Inserting a table with pure JavaScript (not a plugin)

Postby robertotomas » Thu Dec 07, 2017 7:00 pm

Api is exposed from within plugins .. so you can do that in a plugin.

It is important to remember that there is an outer iframe that only office loads into, it isn't exposed in your app/component at all. :)
robertotomas
 
Posts: 21
Joined: Thu Aug 31, 2017 4:05 pm


Return to API

Who is online

Users browsing this forum: No registered users and 1 guest