Rendering a Report from Code
Our sample projects and report templates can help you learn the basics of working with our products.A report can be rendered without a viewer, for example to process the result server-side. This example renders the report and inspects the output.
Code overview. Initialize the required report objects, render a report from code, and handle the resulting state or output.
Code overview. Initialize the required report objects, render a report from code, and handle the resulting state or output.
import { Stimulsoft } from 'stimulsoft-reports-js-react';
function App() {
var report = new Stimulsoft.Report.StiReport();
report.loadFile('Reports/SimpleList.mrt');
async function renderReport() {
await report.renderAsync2();
document.getElementById('message')!.innerText =
'The report rendering is completed. Pages: ' + report.renderedPages.count;
document.getElementById('reportJson')!.innerText = report.saveDocumentToJsonString();
}
return (
<div>
<button onClick={renderReport}>Render the Report</button>
<br />
<br />
<div id='message'></div>
<pre id='reportJson'></pre>
</div>
);
}
export default App;renderAsync2() builds the document pages; afterwards renderedPages.count and saveDocumentToJsonString() give access to the rendered result for saving or further processing.