Word Report Generator for C++

C++ library to build highly customized Word reports using REST API

Seamlessly integrate generation of Word documents based on templates and data sources into your C++ software.

Automate Word document generation in C++, create print-ready Word reports of any complexity with C++ SDK. This Cloud-based solution is built around templates, data sources and a powerful LINQ-syntax, giving C++ developers the flexibility to fit precise technical and business requirements.

Using this C++ library, you can programmatically build highly customized Word reports on any operating system. Richly formatted Word documents like contracts, orders, invoices, shipment reports, sales proposals, inventories can be assembled on the fly as a part of your C++ software.

Streamline Word document generation using C++

The importance of Document Automation and Report Generation has grown immensely over the past decades. Almost every company has a need to generate documents and deliver them to partners or customers on time. Moreover, it is usually a decisive factor in financial success. Implementing such technologies can result in significant financial savings by reducing manual data entry, human error, proofreading and paperwork. For these reasons, document automation and reporting tools are an integral part of many modern software solutions that aim to provide advanced analytical features to users.

Generally speaking, Word report generation is a process that combines text, data and graphics into a single entity and exports the result in a convenient visual form to Word file format. For information on supported I/O formats, please visit our Documentation.

What is GroupDocs Assembly for C++

GroupDocs Assembly for C++ is a Cloud-based solution for generating Word documents using templates and data sources. The document template acts as a base-frame, which, in addition to the standard content (text, tables, charts, etc.), includes special placeholder fields for inserting values from the data source. Not only individual values can be inserted, but also entire arrays of data in the form of tables and graphs.

The template also contains programming constructs - Word document generation rules - that control data selection and condition processing. Binding data to a document template uses LINQ-expression syntax, which allows developers to process data in a generic way, regardless of the type of data source used. In this way, our C++ Cloud SDK gives you flexibility in Word content generation and a powerful set of methods for data processing.

This product also supports Mail Merge functionality in case you want to create and send batches of personalized letters in Word format to customers. You just need to insert Mail Merge fields to the document template and pass it to the Cloud API together with a data source.

Regardless of the scale and type of Word document automation you are going to implement, there are three steps to build a report in C++:

  • Create a Word document template with placeholder fields and document generation rules that will regulate structure and content variations
  • Create a data source in Word or JSON format
  • Write a few lines of C++ code to pass everything to the Document Building API and get the assembled result in Word format back

Designing a document template and using Word document generation rules

Designing templates is a difficult task. In addition to a clear understanding of the requirements for the final Word document, analytical and programming skills are required. A good template design should reflect the customer's view on a particular issue. The most effective approach is to combine tabular data and graphics in the right balance, determined by business requirements.

As mentioned above, the template structure usually contains some fixed blocks of content (text, images, logos, etc.) mixed with special programming constructs that control Word document assembly logic. These Word document generation rules are defined with a special expression syntax, which enables developers to do the following:

  • embed external document content, images, charts, lists, tables, hyperlinks, bookmarks, etc.
  • work with data using formulas and sequential data operations
  • specify the presentation format for numeric, text, graphic, graphic, and date and time elements
  • insert blocks of content depending on conditional expressions
  • define special variables for 'expensive' calculations that are calculated only once
  • calculate formulas when assembling spreadsheet documents
  • assign email message body attributes and dynamically create attachments
  • create and insert barcodes
  • set background color for HTML documents

You can learn more about template syntax in our Developer Guide.

Requirements

GroupDocs Assembly for C++ does not require any external software or third-party tools to be installed. This is a Cloud-based solution for Word, where all programming interactions are performed over the network using the REST API.

Security

All GroupDocs products are fully compliant with industry security standards: data transfer is carried out using the SSL protocol, which eliminates the possibility of information being intercepted by third parties. To connect to GroupDocs Cloud Services, you need to use personal access keys. Please refer to the Quick Start guide.

Generate Word document in C++

The following code example shows how to generate Word reports using C++.

Generate DOCX document in C++
Input files
Upload a document template
Output format
Select the target format from the list
using namespace groupdocs::assembly;
using namespace groupdocs::assembly::cloud::api;

auto config = std::make_shared<Configuration>(L"####-####-####-####-####", L"##################");
auto assemblyApi = std::make_shared<AssemblyApi>(config);
auto fileName = L"Input1.docx";
auto dataFile = L"Input2.docx";

auto requestFileContent = std::shared_ptr<std::istream>(
	new std::ifstream(std::filesystem::path(fileName), std::istream::binary));
std::shared_ptr<UploadFileRequest> uploadDocumentRequest(
    new UploadFileRequest(
        requestFileContent, std::make_shared<std::wstring>(fileName)
    )
);
assemblyApi->uploadFile(uploadDocumentRequest);

auto fileInfo = std::make_shared<TemplateFileInfo>();
fileInfo->setFilePath(fileName);

auto assembleOptions = std::make_shared<AssembleOptions>();
assembleOptions->setSaveFormat("docx");
assembleOptions->setReportData(std::filesystem::path(dataFile));
assembleOptions->setTemplateFileInfo(fileInfo);

auto request = std::make_shared<AssembleDocumentRequest>(assembleOptions);
assemblyApi->assembleDocument(request);
  
Copy C++ code to the clipboard

How to generate Word document using C++

  1. Install 'GroupDocs.Assembly Cloud SDK for C++'.
  2. Add a library reference (import the library) to your C++ project.
  3. Create a template document, add programming constructs that control the insertion of data from the data source.
  4. Create a data source.
  5. Upload the document template to the GroupDocs Cloud Storage (you need to log in to your personal account).
  6. Generate a document by passing your template and data to the Cloud API.

How to install DOCX Report Builder for C++

Clone GroupDocs.Assembly Cloud SDK for C++ source code from GitHub. You can find detailed information on building and configuring the SDK in the "How to use the SDK" section.

To quickly get the necessary security credentials and access our REST API, please follow these Instructions in the documentation.

System Requirements

Refer to the Repository Documentation to see the details.

Other supported document formats

You can generate reports in other file formats:

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2024. All Rights Reserved.