This article describes the functionality of Text Control ReportingCloud - the Web API powered reporting platform to create MS Word compatible reports in the cloud. This product is not available yet and is going to be released soon.

Bjoern Meyer

While preparing the launch of our next product ReportingCloud, we are testing the Web API and building sample applications. ReportingCloud is a smart way to bring your desktop or server application to the web or mobile market. With an easy-to-use, highly available Web API, you can create documents from any client including web, mobile and desktop applications.

Consider the following scenario: Your customer is using a local desktop version of QuickBooks which is installed on an in-house server or desktop. But their users want to create invoices or quotes using a web interface or mobile app on their iOS or Android smart phones.

The Cloud Drivers from CData Software make on-premise data sources accessible across platforms and devices. The data is returned as JSON and can be directly used to merge MS Word compatible templates using ReportingCloud.

Creating reports from QuickBooks or Salesforce data sources using ReportingCloud and CData Cloud Drivers

After installing the CData Cloud Driver for QuickBooks, you can connect the driver to your QuickBooks Desktop or Online account and specify the data tables you would like to access using the cloud driver:

CData Cloud Drivers settings

The CData Cloud Driver runs on your desktop or server and is now accessible from outside using HTTP methods. The following GET method returns all data rows from the table Customers:

GET https://localhost:8032/api.rsc/Customers
view raw tx.cs hosted with ❤ by GitHub

Creating the Template Using ReportingCloud

The above GET method returns a JSON string (simplified in this sample):

{
"@odata.context": "http://localhost:8047/api.rsc/$metadata#dbo.Customer",
"value": [
{
"name": "Petersen",
"firstname": "Klaus",
"id": 1
},
{
"name": "Hans",
"firstname": "Hansen",
"id": 2
}
]
}
view raw data.json hosted with ❤ by GitHub

The data we are interested in is in the value property of the JSON object. In order to create a template, we can copy the data of the value property and paste it into the New Datasource Excerpt File box in the portal of ReportingCloud:

Datasource excerpt file

A datasource excerpt file is used to fill the drop-down lists of the template editor with proper merge fields, relations and dummy data for a template preview. A datasource excerpt file is not your actual data that is used to merge your template. It helps you to design your templates and to insert the proper field names.

The format of the datasource excerpt file is the same as the accepted datasource of the Merge Web API method. It is a JSON string containing an array of objects.

Template editor

The following sample code shows how to call the CData Cloud Driver Web API to get all records from the table Customer. This data is then posted to the ReportingCloud Web API to merge the template with live data from the local QuickBooks database:

using (HttpClient client = CreateHttpClient())
{
// set the endpoint
HttpResponseMessage response = client.GetAsync("api.rsc/Customer").Result;
// return an ActionSettings object, if sucessful
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
List<Customer> customers =
JObject.Parse(result)["value"].ToObject<List<Customer>>();
Report report = new Report()
{
Customers = customers
};
ReportingCloud rc = new ReportingCloud(
"username",
"password",
new Uri("https://api.reporting.cloud"));
MergeBody mergeBody = new MergeBody() {
MergeData = report
};
List<string> results = rc.MergeDocument(
mergeBody, "CloudDriver_Sample.tx");
File.WriteAllBytes("results.pdf", Convert.FromBase64String(results[0]));
}
else
{
// throw exception with the message from the endpoint
throw new ArgumentException(response.Content.ReadAsStringAsync().Result);
}
}
view raw tx.cs hosted with ❤ by GitHub

The Merge method of ReportingCloud returns a list of PDF documents encoded as Base64 strings. The resulting sample document with data from the QuickBooks Customer table is shown below:

Results

Instead of consuming the plain Web API, we built language specific wrappers. They encapsulate all HTTP requests and provide classes to manage templates and to merge documents. In this sample, the ReportingCloud .NET wrapper is used. We also provide wrappers for Java, PHP and Ruby for an easy integration into your applications.

Stay tuned for more details.