Information

 

The Stimulsoft MRT file is a description of reports with XML or JSON markup. You can use MRT files, created in other Stimulsoft designers.

 

 

 

To load a report using PHP code, you can use one of the functions of the StiReport object - loadFile() or load(). Each of the functions takes as input a parameter - the name of the report file:

 

Name

Description

loadFile($filePath, $load = false)

Loads a report from an MRT file on the client-side, the path to which is specified in the function arguments. If the $load parameter is set to true, the report file will be loaded on the server side and passed to the client side as a packed Base64 string.

load($filePath)

Loads a report from an XML or JSON string and sends it to the client side as a packed Base64 string.

 

 

For example, you need to load a report from a file on the server side from a private directory and pass it to the client side:

 

index.php

 

<?php

$report = new \Stimulsoft\Report\StiReport();

$report->loadFile('reports/SimpleList.mrt', true);

$report->renderHtml();

?>

 

 

 

To load a report using JavaScript code, you can use one of the functions of the StiReport object - loadFile() or load().

 

Name

Description

loadFile(filePath)

It loads a report from a MRT file, the path to which is specified in the function arguments.

load(str)

It loads a report from the string, which contains the report in XML or JSON format.

load(data)

It loads a report from data array of the number[] type.

load(xml)

It loads a report from an XML object of the XMLDocument type.

load(json)

It loads a report from an JS object.

 

 

For example, you need to load a report from a file.

 

index.php

 

var report = new Stimulsoft.Report.StiReport();

report.loadFile("reports/SimpleList.mrt");

 

 

 

Additional report formats

Additionally, a report template can be presented in the Stimulsoft MRZ format (a packed report) and the Stimulsoft MRX format (a password-encrypted report). The MRZ format allows you to save files with smaller size, not using other utilities of packaging. The MRX format is encrypted with a password and allows you to hide confidential data, saved in your report.

 

There are special functions to load a report in the formats mentioned above.

 

Name

Description

loadPackedFile(filePath)

It loads a packed report from a MRZ file, the path to which specified in the function arguments.

loadPacked(str)

It loads a packed report from the string, which presented in the Base64 format.

loadPacked(data)

It loads a packed report from data array of the number[] type.

loadEncryptedReportFile(filePath, key)

It loads an encrypted report from a MRX file, the path to which specified in the function arguments. You should specify string encryption key, which set when saving.

loadEncryptedReport(str, key)

It loads an encrypted report from the string specified in the Base64 format. You should specify string encryption key as the second argument, which set when saving.

loadEncryptedReport(data, key)

It loads an encrypted report from the number[] data array type. You should specify the string encryption key as the second argument, which set when saving.

 

 

To save a report you can use the following functions.

 

Name

Description

saveToJsonString()

It saves a report as a row in the JSON format.

savePackedToString()

It saves a report as a row, presented in the Base64 format.

savePackedToByteArray()

It saves a packed report as an array of the number[] data type.

saveEncryptedReportToString(key)

It saves an encrypted report as a row, presented in the Base64 format. You should specify a string encryption key as argument.

saveEncryptedReportToByteArray(key)

It saves an encrypted report as an array of the number[] data type. You should specify a string encryption key as argument.

 

Information

 

The Stimulsoft Reports.PHP report generator and the Stimulsoft Dshboards.PHP dashboards based on the JavaScript platform, and they support saving MRT files in the JSON format only. MRT files in the XML file are supported in the loading mode only. In addition, they will be automatically converted to the JSON format when saving.

 

 

 

Loading and saving documents (rendered reports)

A rendered report can be saved as a document in the JSON format for further view or export. Such document contains rendered report pages, but it doesn't contain initial data and doesn't save the connection to them. For example, you need to save the document in the JSON string.

 

To load a document using PHP code, you can use one of the functions of the StiReport object - loadDocumentFile() or loadDocument(). Each of the functions takes as input a parameter - the report file name:

 

Name

Description

loadDocumentFile($filePath, $load = false)

Loads a document from an MDC file on the client-side, the path to which is specified in the function arguments. If the $load parameter is set to true, the document file will be loaded on the server side and passed to the client side as a packed Base64 string.

loadDocument($filePath)

Loads a document from an XML or JSON string and passes it to the client side as a packed Base64 string.

 

 

For example, you need to load a document from a file on the server side from a private directory and pass it to the client side:

 

index.php

 

<?php

$report = new \Stimulsoft\Report\StiReport();

$report->loadDocumentFile('reports/SimpleList.mdc', true);

$report->renderHtml();

?>

 

 

Information

 

So as you always need data to create dashboards, they can't be saved as a document. The Stimulsoft Dashboards.PHP supports saving dashboards as a template only.

 

 

 

The corresponding functions of the StiReport object are used to load and save a document using JavaScript code. The full list of functions and parameters you may find in the table below.

 

Sample of document loading from a file:

 

index.php

 

var report = new Stimulsoft.Report.StiReport();

report.loadDocumentFile("reports/SimpleList.mdc");

 

 

 

Here is a sample of loading a report template, building it and saving the rendered document as a JSON string:

 

index.php

 

var report = new Stimulsoft.Report.StiReport();

report.loadFile("reports/SimpleList.mrt");

report.renderAsync(function() {

var jsonString = report.saveDocumentToJsonString();

});

 

 

 

A document can be presented in three different formats as well as report template: Stimulsoft MDC (a simple document), Stimulsoft MDZ (a packed document) and Stimulsoft MDX (an encrypted document by a password). A full list of functions to work with all document formats is in the following table.

 

Name

Description

loadDocumentFile(filePath)

It loads a document from a MDC file, the path to which specified in the function arguments.

loadDocument(str)

It loads a document from the string, which contains a report in the XML or JSON.

loadDocument(data)

It loads a document from data array of the number[] type.

loadDocument(xml)

It loads a document from an XML object of the XMLDocument type.

loadDocument(json)

It loads a document from a JS object.

loadPackedDocumentFile(filePath)

It loads a packed document from a MDZ file, the path to it specified in the function arguments.

loadPackedDocument(str)

It loads a packed document from the string, presented in the Base64 format.

loadPackedDocument(data)

It loads a packed document from data array of the number[] type.

loadEncryptedDocumentFile(filePath, key)

It loads an encrypted document from a MDX file, the path to it specified in the function arguments. You should specify the string encryption key set when saving as the second argument.

loadEncryptedDocument(str, key)

It loads an encrypted document from the string presented in the Base64 format. You should specify the string encryption key set when saving as the second argument.

loadEncryptedDocument(data, key)

It loads an encrypted document from data array of the number[] type. You should specify the string encryption key set when saving as the second argument.

saveDocumentToJsonString()

It saves a document as the string in the JSON format.

savePackedDocumentToString()

It saves a packed document as the string presented in the Base64 format.

savePackedDocumentToByteArray()

It saves a packed document as data array of the number[] type.

saveEncryptedDocumentToString(key)

It saves an encrypted document as the string presented in the Base64 format. You should specify the string encryption key as the second argument.

saveEncryptedDocumentToByteArray(key)

It saves an encrypted document as data array of the number[] type. You should specify the string encryption key as the second argument.

 

Information

 

When saving a document from the viewer menu, a file is saved in the JSON format too, and it has the MDC expansion for a standard document, the MDZ for a packed document, the MDX for an encrypted document.