KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Single Page return html as string #1644

Closed Matt Jacobson opened this topic on on Oct 2, 2020 - 1 comments

Matt Jacobson commented on Oct 2, 2020

I'm trying to create a Single Page report that will return the rendered html to a variable (so it can be returned to a calling function). I know when I call $foo = $report->run()->render("viewfilename", TRUE), it will return the html to the variable. Is this possible with Single Page?

David Winterburn commented on Oct 5, 2020

Hi Matt,

I think you can retrieve content of a single page report to a variable as well. Please try this code:

//Define single page report class here
...
ob_start();
$report = new SinglePageReport;
$report->start();
?>

<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <h1>Testing</h1>
        <?php
        Table::create(array(
            "dataSource"=>$report->dataStore('mydata')
        ));
        ?>
    </body>
</html>

<?php $report->end(); 
$content = ob_get_clean();
echo $content;
?> 

Let us know if we understand your question correctly.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Instant