Jump to content

Help with rendering MSSRS - Reporting services


Lyleyboy

Recommended Posts

Hi all,

 

I have a problem with trying to render a report from MS SQL Server Reporting services using PHP.

 

I have happliy get the report to display in HTML or PDF but I really need it to be in Excel.

When I set it to export to excel it does open a document but it is filled with rubbish.

 

My code


<?php 


ini_set("soap.wsdl_cache_enabled", "0");

ini_set("default_socket_timeout", "120");
set_time_limit(120);

DEFINE('Cache', 'NULL');
DEFINE('CSV', 'CSV');
DEFINE('Excel', 'EXCEL');
DEFINE('HTML', 'HTML4.0');
DEFINE('PDF', 'PDF');
DEFINE('TIFF', 'IMAGE');
DEFINE('WebArchive', 'MHTML');
DEFINE('XML', 'XML');

$report = "/REPORT GOES HERE";
$format = "HTML4.0";
$devInfo = "<DeviceInfo><Toolbar>True</Toolbar><Parameters>True</Parameters></DeviceInfo>";
$result = array();
$extension = "";
$mimeType = "";
$encoding = "";
$warnings = array();
$streamIDs = array();
$historyID = null;
$paramLang = "en-us";

$namespace      = "http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices";
$serviceEndPt   = "http://192.168.xxx.xxx/reportserver/ReportService.asmx?wsdl";
$executionEndPt = "http://192.168.xxx.xxx/reportserver/ReportExecution2005.asmx?wsdl";

try {

  $execclient = new SoapClient($executionEndPt,
                            array('login'=>"username", 'password'=>"password"));


  $loadReportParam = array( 'Report' => $report,
                            'snapshotID' => $historyID
                          );
  
  $execInfo = $execclient -> LoadReport($loadReportParam);
  $executionID = $execInfo->executionInfo->ExecutionID;
  
  $setExecParam = array('ExecutionID' => $executionID);

  $execHeader = new SoapHeader (
                $namespace,
                'ExecutionHeader',
                $setExecParam
                );

  $execclient->__setSoapHeaders($execHeader);


  $reportParams = array ( array('Name' => 'dtStartDate', 'Value' => "2010/01/01", 'Label' => NULL),
                          array('Name' => 'dtEndDate', 'Value' => "2010/06/06", 'Label' => NULL),
                          array('Name' => 'nvcClient', 'Value' => "DETAIL", 'Label' => NULL)
                                                  );

  $sepResult = $execclient->SetExecutionParameters(array("Parameters"=>$reportParams), $paramLang);

  if ($debug)
    varDump ('SetExecutionParameters',$sepResult);

  
  $renderParams = array ( 'Format' => $format,
                          'DeviceInfo' => $devInfo
                        );

  $rrResult = $execclient -> Render($renderParams);

  header('Content-Type:'.$rrResult->MimeType);
  echo $rrResult->Result;
} 
catch (SoapFault $e) {
  var_dump($e);
}



?>

I have obliterated certain bits a detail for security purposes.

 

Does anyone know what I'm doing wrong?

 

Thanks in advance

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.