I have a query. I need to create a form with a questionnaire, which I need to distribute to users to fill in and send back to me completed (It should be an offline file to send by email). The idea is to use OnlyOffice “PDF Form” and then I need to connect them (some fields) with an excel spreadsheet or OnlyOffice spreadsheet to extract the data and make a statistic.
Any idea how to connect those fields with a spreadsheet?
I’m afraid there is no way to achieve it with PDF. However, something similar can be achieved for DOCXF with Document Builder. For instance, you can get values of all forms with GetAllForms, then get content of specified form with GetText and using GlobalVariable put it into a cell in needed spreadsheet. Simple example of such .docbuilder script:
builder.OpenFile("new.docxf");
var oDocument = Api.GetDocument();
var aForms = oDocument.GetAllForms();
var oItem1 = aForms[0].GetText();
GlobalVariable["oValue"] = oItem1;
builder.CloseFile();
builder.OpenFile("Book1.xlsx");
var oWorksheet = Api.GetActiveSheet();
var oItem1 = GlobalVariable["oValue"];
oWorksheet.GetRange("A2").SetValue(oItem1);
builder.SaveFile("xlsx", "Book1.xlsx");
builder.CloseFile();
This script will get value of first form field on DOCXF, open spreadsheet and then paste the value of the field into cell A2.
Hello Constantine! Thanks for your answer! It would be a solution, but from what I understand, end users should fill out the forms in OnlyOffice and with .docxf? If so, the problem is that the universe is very varied, some use MS Word, others LibreOffice, OpenOffice, and OnlyOffice…