C++ samples guide
Before you start
For the samples to work correctly, make sure that two conditions are met:
- ONLYOFFICE Document Builder is installed into default directory "C:/Program Files/ONLYOFFICE/DocumentBuilder" on your computer.
- The directory in which you are going to store the downloaded samples has general editing access to save files created by the Document Builder.
Download a sample
Download one of the Builder C++ samples and copy it into a folder with general editing access.
- Filling spreadsheet
- Commenting spreadsheet errors
- Creating presentation
- Creating chart presentation
- Creating basic form
- Creating advanced form
- Filling form
Sample structure
Each sample includes a code folder, an sln file, and a template file if the sample uses a template.
The code folder consists of a C++ program file and project files.
Please note that the path to the DocBuilder .dll file in the project file is set to default. You can change the path in the Sample.vcxproj.user file if DocBuilder is located in a different directory on your computer.
Program structure
- Include doctrenderer library C++ wrapper
- Specify the paths to the Document Builder work directory, the result path (where the generated file will be saved), and the optional template path (if a template file will be used).
- Create the main function (this function works with the DocBuilder methods to edit documents).
- Initialize the DocBuilder from the working directory. After that Builder opens or creates a file so that Context, Scope and Global classes can be accessed.
- Edit file using DocBuilder API methods. Use Call method with the name and params of the API method you call as an arguments.
- Save and close file after editing, then call the Dispose method to destroy DocBuilder.
Run the sample
Open .sln file inside the sample folder to build the project.
Run the program when the project is built.
Check the result
After program execution the result file will be saved to the result path. It's sample folder root by default.
Open result file and check the result.