StiMobileDesigner - ASP.NET компонент для создания и редактирования отчетов в браузере. В этой статье мы расскажем об использовании данного компонента на облачной платформе Azure.

В первую очередь стоит заметить, что компонент StiMobileDesigner основан на технологии клиент-сервер. На серверной стороне находится кэш, то есть ячейка для хранения информации с быстрым доступом. Из кэша можно в любой момент получить необходимый объект или же наоборот загрузить его в кэш. Но если загрузить дизайнер отчетов на Azure, то сохраняемый вариант объекта может быть сохранён в различных экземплярах сервера. Поэтому при сохранении отчета в различные экземпляры сервера в кэше возникает проблема его хранения. Для корректной работы необходимо, чтобы отчет сохранялся в один и тот же кэш.

Для решения этой проблемы наши разработчики создали класс StiCacheHelper для каждого из следующих компонентов: StiMvcMobileDesigner, StiMvcMobileViewer, StiMobileDesigner, StiMobileViewer и вынесли из дизайнера два внешних метода: SaveObjectToCache и GetObjectFromCache. Внутри этих методов пользователь может описать свое собственное сохранение в кэше и собственное изъятие объекта из кэша. Другими словами, необходимо переопределить метод и сохранять любые объекты в свой собственный кэш, что значительно упрощает и ускоряет работу с отчетами на облачной платформе Azure.

classStiAzureCacheHelper : StiMobileViewer.StiCacheHelper
    string SlsPath = RoleEnvironment.GetLocalResource("TestStorage").RootPath + "\\";
    public override void SaveObjectToCache(object obj, string guid)
        byte[] cacheData = GetCacheDataFromObject(obj);
        System.IO.File.WriteAllBytes(SlsPath + guid, cacheData);
    public override object GetObjectFromCache(string guid)
        if (!System.IO.File.Exists(SlsPath + guid)) return null;
        byte[] cacheData = System.IO.File.ReadAllBytes(SlsPath + guid);
        return GetObjectFromCacheData(cacheData);
StiMobileViewer1.CacheHelper = new StiAzureCacheHelper();
Using the SQL queries helps avoiding the data duplication in the tables and provides maximum flexibility when searching and showing the data in a database. This also allows requesting only required data, fields, registers etc.

One of the ways to get only required data is using parameters. When you create a query you can use Parameter. It is used to pass additional information into the query for selecting data. For example, you can create a query with parameters when it is required to use some values in the query during every execution of this query. The object Parameter can be used only together with SQL data sources.

More information about it can you read in our documentation.

Also you can create parameters from the code:

Dynamic SQL
Working with parameters in Stimulsoft Reports software is similar to the parameters in the .NET Framework.

Using variables in parameters

In Stimulsoft Reports you can use Variables in the report. The Variable provides an ability of placing and using a variable when creating reports. The variables can be of different types such as string, date, time, array, collection, range etc. All variables are stored in the data dictionary. Before you will use any variable, you should add it to the data dictionary. More information about this can be found in our documentation.

Variable in Parameter

Values to variables can be set from code or by request from the user. There are two ways how to do this from code. It depends on with which report (compiled or not) the user works.

before compilation:

Variable in SQL
after compilation:

Variable in SQL
When you request the value of the variable from the user, you should set the parameters on the panel Request from user. These parameters determine possible involvement of the user when applying a variable in the report. Possible values of variables the user can get from the data source, specifying it in the Data Source property. For correct work of this functionality you should get data for all data sources, and then request the selection of the values for variables from the user. If possible values are not taken from the data sources and values selected by a user are used in queries, then, in order to avoid requesting all the data once again, it makes sense to set the Request Parameters property of the report to true.

In our reporting tools you can use the variables directly in the query. The value of the variable will be inserted into the query directly before its execution without some additional actions. For example, when the query is:

Query Type
and a value of the variable is Chocolate, then in this case the next query will be executed:

Variable Chocolate
Naturally, this query will not be executed. The correct query is the next one:

Query Type
You can find this feature only when working with strings, but this behavior allows creating more difficult queries dynamically in contrast to values of variables. The similar example is shown below.

Using variables to output lists

From time to time you need to create more complex queries. For example, when, on one hand, you need to get data from the data source to give a choice for a user, and on the other hand, some queries may not be executed, because the required parameters are not set. In this case we a have a problem.

One of such examples. The variable with enabled option Request from user can be used both for selecting several values and in the operator IN of the SQL query.

You need to know one thing. By default the variables of the type List are filled only after connection of the dictionary to data sources. Therefore, during the first connection of data source this variable will be empty, and the expression Variable1.ToQueryString() throws an empty string and, accordingly, the entire query throws the error. To avoid this we have added an additional check.

In this example all data will be shown and after you click the button Submit the report will be rebuilt using only selected data.

When you need to view only required data, you should do the following:

1. Set the report property report.RequestParameters to true. And, before the first click of the button Submit, only the empty report page will be viewed and rendering will begin after the click.
2. At once initialize the report variable with additional values.

Required Data
Let's discuss a very important thing – creating an OLEDB connection under a 64-bit OS with use of the adapter Microsoft Jet 4.0. This adapter is not supported in 64-bit applications. But the issue can be solved in several ways and takes this a couple of minutes. Despite the fact that the database adapter Microsoft Jet is present in Windows 7, it is a bit outdated. Therefore, you should use the new adapter Microsoft.ACE.OLEDB.12.0. This adapter can be downloaded from the official source, completely free of charge.

Once you have downloaded it. Install it. Run the file, accept the license agreement, define the installation location and wait for a while. It takes a couple of minutes. After the installation is finished, it is better to restart the report designer (if opened), and in case the installation wizard offers to restart the system, just follow its request. Next, create an OLEDB connection to the data source.

It should be noted that this adapter is designed exclusively for 64-bit applications; it will not work with 32-bit versions of Microsoft Office. Therefore, Microsoft.ACE.OLEDB.12.0 should be used only with 64-bit versions of the Office.

Here is a video that shows how to install the adapter Microsoft.ACE.OLEDB.12.0 and create the OLEDB connection to the data source.

Also, this problem can be solved without the adapter Microsoft.ACE.OLEDB.12.0. You can change the properties of your project. Go to the properties of the project by selecting the appropriate item from the context menu, or by Project -> Properties..., in the tab Build change the Platform target, selecting the value x86. After this, run the project, call the designer and create the OLEDB connection to the data source. This method can be watched the video below.
Dear existing and potential users of the software products Stimulsoft Reports! We continue our series of articles on the optimization of reports. In the previous article of this series we dealt with the theme of creating reports, but as the work with reports does not end with its rendering, so optimization does not end with optimization processes when designing reports.

Today we will share you some tips to help you be able to not only significantly improve the appearance of the final report, but also reduce the amount of resources used, as well as speed up work with reports. Итак, оптимизация экспорта отчетов:

Borders and grid alignment

When exporting reports, our users are often facing with many extra columns in the Excel table. But are they superfluous? After all, each cell corresponds to the border of any component on the page. Otherwise, you cannot display a lot of components scattered across the page. Therefore, when using a table export mode, it is recommended to use the following tips: - Use the button Align to Grid. This will reduce the number of rows and columns in the ready file. The image below shows it very clearly: when exporting, the report on the left will have 25 cells, and the report on the right - only 3. This will help to avoid the very small gaps between components (some formats "do not like", when columns of the table are obtained by a very small size); - Place components in a Data band at the same level. This will reduce the number of rows and columns in the output file as in the previous section.

Borders in reports

Using a Data band instead of Tables

The data can be output from the data source in a report using the Table component or the Data band. The Table is a complex component that is based on the Data band. In the process of rendering a report, the report engine itself decomposes the Table into a Header, Data band, and Footer. When rendering a simple report as a solid table, there is no significant difference between the Table and Data band components, in mdc-files. When rendering a complex report, for example, a table with blank columns, merged with cells in the header and footers etc. The difference might be more noticeable. The Data band component is more flexible in using (although more complex) that allows you to create a more optimized template. For example, for an empty column you may not add a text component, there is no need to merge cells, etc. In the table, an empty cell is not empty and processing and storage requires additional time and resources. Therefore, when you use the Table component, time for the report creation may increase, and the size of the .mdc report file can be larger.

Using graphic primitives

Exporting reports can be faster and easier when you can use graphic primitives instead of the more "heavy" component Shape. Graphic primitives are vertical and horizontal lines, rectangles that are used to create borders of components. A shape is often exported to other formats such as picture, which significantly increases the volume of the exported report.

RichText component

To speed up the export of the rendered report, we recommend you use several ordinary components instead of the RichText component. Since the RichText component is complex, there is the complexity of its processing, for example, because of the use of the system libraries that handle the report quite a long time. Also many formats do not recognize such a text, and it will have to export it as a picture, which can significantly increase the size of the output file. Then there are certain difficulties in the editing of the document.

Rich Text

We should also mention the process of working with reports in the Web - directly in the web browser. This process goes only by means of the browser itself. Some manufacturers use reporting tools Active-X-components to extend the functionality, but these components work only in Internet Explorer. We do not limit our customers which web browser to choose for working with reports. However, we recommend our users do not build very large reports, multi-page reports with a huge amount of data in the web browser. It is caused not only by the fact that the means of the browser considerably limit capabilities for working with reports, but also by the fact that the report rendering goes on web servers, which often have limited resources. For large reports, we recommend splitting them up into smaller reports, and use filters to limit the amount of data displayed. It is unlikely that users will bring pleasure to flip through hundreds of pages in a browser.

Dear friends, we continue our series of articles on optimizing reports. Last time we talked about the basics of optimizing directly when creating reports. As for advice for advanced, experienced users of our software products, today we offer a few suggestions to help you avoid unnecessary costs.

As in the previous article, we divided the optimization into two main categories: increasing the speed of rendering reports and reducing memory used for generating reports . So, let’s get started:

Avoid using the Sub-Report component

To speed up report rendering, we recommend you stop using sub-reports in favor of using the DataBand component. The main reason for this recommendation is that, when rendering the Sub-Report, one page of infinite height is created. In the end of rendering this page is broken. This leads to numerous subsequent checks. When using the DataBand component, contents are fully laid out in the main report. In addition, the engine of our reporting tool is highly optimized to work with the DataBand component.

Sub Report

Working with the Report Checker utility

In Stimulsoft Reports, the Report Checker is used for checking the report on errors. This component analyzes the report, resulting in information and error messages or alerts found in reports. If any errors occur while rendering a report, then the Checker generates messages and offers solutions for some of them. For example remove a component, move it to the print area, enable or disable properties, and so on. This will significantly speed up the process of rendering reports.


Interpretation mode

In the interpretation mode the compilation does not occur. So time and memory is not used. It is very important, especially when a report has a great number of components. However, it should be noted that this mode is relatively new, so you may have some issues with this. For example, incorrect handling of complex expressions. Also scripts, used in the report events, are not working in this mode.

Connecting assemblies

Another method of increasing the speed of report building and reducing memory usage is a compilation of the report as an assembly - .dll file. The main advantage of this method lies in the fact that the compilation occurs only once. The next time already compiled report is loaded. There is one issue with this. When updating to the latest product version, you have to re-compile a report from a template (.mrt file) into the assembly. Otherwise some errors may occur.

Working with the Table component

Table is a compound component. If you render complex reports, it is better to replace it with a band, because the Table consists of a set of items and rebuilding of each item involves a number of checks by all the other items and, if your report has a complex structure, some issues may occur with wrapping and breaking table cells. This component is good to create reports fast, but it slows the rendering process. It can be used in creating simple lists reports and reports without a very complex structure. In other cases it is desirable to replace it with a band.

Table Band