Sử dụng các phần tử giao diện tùy chỉnh để tương tác với nội dung tài liệu từ bên ngoài — tự động điền dữ liệu, chạy macro, xử lý sự kiện.
✓Tự động điền dữ liệu từ database vào template
✓Chạy macro JavaScript trong editor
✓Bắt sự kiện: save, open, error, ready
✓Tích hợp với workflow doanh nghiệp (ERP, CRM)
✓Hỗ trợ .docx .xlsx .pptx .pdf
automation.js
// Kết nối với ONLYOFFICE editor
var connector = docEditor
.createConnector();
// Tự động điền dữ liệu
connector.executeMethod(
"InsertText",
[{ text: "Họ tên: Nguyễn Văn A" }],
function(result) {
console.log("Done:", result);
}
);
// Lắng nghe sự kiện
connector.attachEvent(
"onDocumentReady",
function() {
console.log("Editor sẵn sàng!");
}
);
builder.js
// Tạo tài liệu Word từ code
var oDoc = Api.CreateDocument();
var oSection = oDoc
.GetFinalSection();
oSection.SetPageSize(
12240, 15840
);
// Thêm tiêu đề
var oParagraph = Api
.CreateParagraph();
oParagraph.AddText(
"BÁO CÁO THÁNG 5/2026"
);
// Lưu thành .docx
builder.SaveFile(
"docx",
"bao-cao.docx"
);
Document Builder
Tạo tài liệu DOCX, XLSX, PPTX và PDF từ template hoặc từ đầu — không cần cài đặt Microsoft Office trên server.