How to save a report to cloud services using FR VCL 6

We usually download and save reports on a local drive when working with a desktop application. An alternative to this is the client server application. The reports will be stored on a remote server. But, what if there is no way to deploy a remote server, and you want to store reports on a shared resource?

Of course, you can manually migrate your reports to web repositories. However, FastReport VCL 6 offers us a much more convenient way - storing reports in cloud services.

Cloud services have become popular due to their reliability and data security. Almost every modern cloud storage provide OAuth2 authentication, which greatly simplifies access to data for client applications.

Ultimately, you get a reliable data storage with the ability to access third-party data.

What does FastReport VCL 6 offer? It gives an ability to save reports in four cloud services: DropBox, GoogleDrive, OneDrive, Box.com. And you can save not only the prepared report in the format. Fp3 or export, but the report template itself in the .fr3 format.

Access to the data is performed by application. I want to consider two examples of creating such applications:

 

By the example of Google Drive.

1)      You need to create a project beforehand. You can do this in the Developers Console:

https://console.developers.google.com/

Click on the title "Create application". Then enter the name of the application and accept the terms of use that Google offers you.

2)      Now, in our project, you need to add the Google Drive API library. This can be done on the "Library" tab. So, select the library and click the "Enable" button.

3)      To use the connected library, we are prompted to create credentials. Click the button "Create credentials".

Next, we need to choose where the API will be called from. I chose "Other, with user interface".

Choose the way to access data - user data.

Set the OAuth 2.0 client ID. Enter an arbitrary name (for example, TestUser) and click the button "Create Customer ID".

4)      Next we are offered to download the json file with credentials. We press "Not now".Next we are invited to download a json-file with credentials. We click "Not now". Now, in the "Credentials" tab we have TestUser. Click on this name and go to the client's credentials. Client ID and Client Secret, we will use in FastReport when saving or loading the report.

 

The example of DropBox.

To work with its API, we need to create an application on the platform of this service.

1) Log in to the web page https://www.dropbox.com.

2) Create a new application here: https://www.dropbox.com/developers/apps/create.

Choose the type of application - Dropbox API.

3) In the second step, select the type of access - access only to the application folder or to the entire repository. We choose the first option.

4) In the third step, specify the name of the application. Here it is necessary to try not to repeat the existing one.

5) On the application settings page we see App Key. On this page, we need to add Redirect URIs. After authorization in DropBox it is necessary to return to your web application. To do this, you need to specify a Redirect URI. But, since I do not have a web application I am giving a link to the local computer - http://localhost.

Now you can access the DropBox from FastReport.

So, we looked at two examples of creating applications with the cloud storage API. For the OneDrive and BOX.com services, you will also need to use the API through the application.

Now let's see how to save and load reports from cloud storage.

As you remember, we have two save formats available - fr3 and fp3. The first is the format for storing the report template, the second is the format for storing the prepared report, that is, the template filled with data.

To save the report template (fr3) to the cloud service, use the File-> Save As menu. Next, choose one of the available cloud services:

 

1)      If you select Dropbox, the following window appears:

 

Here we enter the application key, if necessary, select the save directory in your Dropbox. Next, you can enter your login and password from your Dropbox account, but the security will suffer. So, we ignore this option and click OK.

The Proxy tab contains the Proxy settings accordingly, if necessary:

After that, we will be offered to authorize in the DropBox service and allow the application to access the data.

As a result we receive a window with contents of a folder of our application in DropBox. For the time being it is empty. Let's save the report:

 

 2) If you select GoogleDrive, you will get the window:

Here everything is clear, enter the client ID and secret code that you received when creating an account in the project on GoogleDrive. Click Ok.

In this case, the application will request permission to access the data. We press the "Allow" button and get the contents of the repository:

For clarity, the folder already has one saved report.

3) If you chose OneDrive, when saving, you will see this window:

It reminds us of the connection window to DropBox. Here an application identifier is required as well. After authentication, we will get a file saving window:

4) If you chose BOX.com. In this case, we'll see a connection window similar to GoogleDrive:

Enter the client ID and secret key. After authentication, we'll see the save file:

 

To open a report saved in the cloud service, we also use the File-> Open menu:

Here, the forms of connection to the services are absolutely the same as when saving. Only the last window differs. Now this is the file selection window:

Now about saving the file of the prepared report. To do this, you must run the report in preview mode. To save, use the diskette icon:

You will not be able to open the report in fp3 format. Perhaps in the next versions this option will appear.

To save the export to the cloud service, click on the diskette icon and select the desired export format. On the export settings form, choose where to save it:

Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.
Trustpilot