We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

PHP API - Generating a Report

The https://products.aspose.cloud/words/php/report/ page shows a graph with LINQ expressions.

Is the graph created in the document via the PHP API or is it done within the word document?

If the graph is a part of the word document it would be useful to be able to download the template.docx used in the code to see how the graph is setup - is this available?

@FFSPUD

We will provide you specified template document soon. Meanwhile, you can check the following documentation and github repo for more Reporting engine templates.

@FFSPUD

Please find the required sample template and data file along with the sample code.

<?php

require_once('D:\xampp\htdocs\aspose-words-cloud-php-master\vendor\autoload.php');


try {

	//TODO: Get your ClientID and ClientSecret at https://dashboard.aspose.cloud (free registration is required).		
	$ClientSecret="xxxxxxxxxxxxxxxxxxxxxxxx";
	$ClientId="xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx";


	$wordsApi = new Aspose\Words\WordsApi($ClientId,$ClientSecret);	
	
        $reportingFolder = "data";
        $localDocumentFile = "Chart.docx";
        $localDataFile = file_get_contents($reportingFolder . "/Chart.json");

        $requestTemplate = $reportingFolder . "/" . $localDocumentFile;
        $requestReportEngineSettings = new Aspose\Words\Model\ReportEngineSettings(array(
            "data_source_type" => "Json",
            "json_data_load_options" => new Aspose\Words\Model\JsonDataLoadOptions(array("exact_date_time_parse_formats" => array("dd.MM.yyyy")))
        ));
        $request = new Aspose\Words\Model\Requests\BuildReportOnlineRequest(
            $requestTemplate,
            $localDataFile,
            $requestReportEngineSettings,
            NULL
        );

        $result = $wordsApi->buildReportOnline($request);
        copy($result->getPathName(),$reportingFolder . "/Chart_out.docx");
	//print_r($result);
        
} catch (Exception $e) {
    echo  "Something went wrong: ",  $e->getMessage(), "\n";
    PHP_EOL;
}

?>

Chart.zip (21.2 KB)

Thank you for supplying the Word document and sample code.

1 Like