Question- Insert data of Excel into Document or PowerPoint at particular Page or Slide
- I have a excel containing the data of Employee ( employee name, Id, designation )
- We have an existing template in Document(docx) and PowerPoint(pptx)
- Now we want to fetch and set that excel data into these templates of Document(docx) and PowerPoint(pptx)
- Will this be doable ? If so please suggest us.
Hello @qwert12345
I believe you can achieve desired scenario with DocBuilder. I have recorded my test, please take a look at it:Monosnap
Sample of my docbuilder script:
builder.OpenFile("path_to_file\file.xlsx");
var oWorksheet = Api.GetActiveSheet();
var oRange = oWorksheet.GetRange("A1:C4");
var text = oRange.GetText();
GlobalVariable["1"] = text
builder.CloseFile();
builder.CreateFile("docx");
var text = GlobalVariable["1"];
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("Data from xlsx file: " + text);
builder.SaveFile("docx", "path_to_file\newfile.docx");
builder.CloseFile();
Links for reference:
https://api.onlyoffice.com/docbuilder/howitworks/globalvariable
https://api.onlyoffice.com/docbuilder/spreadsheetapi/apirange/gettext
https://api.onlyoffice.com/docbuilder/textdocumentapi/apirange/addtext
1 Like
Thank you for the response @Alexandre
We are using java-spring project for the above scenario that’s is document-server-integration/web/documentserver-example/java-spring at master · ONLYOFFICE/document-server-integration · GitHub
And you have suggested doc builder which works for pup ruby .net c++
Do we have any relevant code /method /library for java
Hello @qwert12345
In my test I used stand-alone DocBuilder(exe), but you can send requests to your installed Document server: ONLYOFFICE Api Documentation - Web Document Builder API
As you can see, it doesn’t matter which programming language was being used for your storage, you can still send requests to DocBuilder (which is the part of installed Document server).
As mentioned above, We have followed the page
this is the cURL of the POST request
curl 'http://localhost/docbuilder' -H 'Content-Type: application/json' -H 'Authorization: Bearer <token>' -d '{
"async": true,
"url": "D:\\code\\OnlyOffice-Service\\createFile.docbuilder"
}'
We see 200 status code but we do not see the response of field “url”
@Alexandre
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oRun;
oParagraph = oDocument.GetElement(0);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Dear John Smith.");
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("ONLYOFFICE is glad to announce that starting today, you are appointed Commercial director to the company of your dream.");
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oRun = Api.CreateRun();
oRun.SetBold(true);
oRun.AddText("Please note: ");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.AddText("this text is used to demonstrate the possibilities of ");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.SetBold(true);
oRun.AddText("ONLYOFFICE Document Builder");
oParagraph.AddElement(oRun);
oRun = Api.CreateRun();
oRun.AddText(" and cannot be used as real appointment to the position in any real company.");
oParagraph.AddElement(oRun);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Best regards,");
oParagraph.AddLineBreak();
oParagraph.AddText("ONLYOFFICE Document Builder Team");
oDocument.Push(oParagraph);
builder.SaveFile("docx", "SampleText.docx");
builder.CloseFile();
Hello @qwert12345
I used your sample with my test servers. For the file storage I used http server (npm), Document server - the latest version (7.3.3)All things are OK, docbuilder returned the link to output result.
Please make sure that Docbuilder is available to get .docbuilder file from your storage and you’re using the latest version of Document server. If it doesn’t help, please try to check out Document server logs, probably you will find error entries.
By the way, try to send request via token in AuthorisationJwt header as I did it on the screenshot.