本文整理汇总了PHP中COM::OpenReport方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::OpenReport方法的具体用法?PHP COM::OpenReport怎么用?PHP COM::OpenReport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COM
的用法示例。
在下文中一共展示了COM::OpenReport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_pdf
private function print_pdf($query = "", $param = array(), $db)
{
if (file_exists($this->pdf_name)) {
if (!unlink($this->pdf_name)) {
echo "Failed to clear temp. please try again";
}
}
try {
$ObjectFactory = new COM("CrystalRunTime.Application") or die("cannot load cr com");
$creport = $ObjectFactory->OpenReport($this->rpt_name, 1) or die("Couldn’t open report");
$ObjectFactory->LogOnServer('PDSODBC.DLL', 'mysql_' . $db, $db, 'root', 'mysql');
//$creport->RecordSelectionFormula="{company.company_name}='AL RUSHAID CONSTRUCTION CO. LTD.'";
//$creport->RecordSelectionFormula="{ogmr.job_no}='530'";
$creport->RecordSelectionFormula = $query;
//$creport->RecordSelectionFormula= mysql_real_escape_string($query);
$creport->EnableParameterPrompting = 0;
$creport->DiscardSavedData;
$creport->ReadRecords();
if (count($param) > 0) {
for ($i = 1; $i <= count($param); $i++) {
$field = $creport->ParameterFields($i);
$end = strlen(substr($creport->ParameterFields($i)->Name, 2)) - 1;
$paramName = substr($field->Name, 2, $end);
$res = @$field->SetCurrentValue($param[$paramName]);
if ($res != 0) {
return "Failed to create report. Failed to set parameter {$i} with value " . $param[$i];
}
}
}
$creport->ExportOptions->DiskFileName = $this->pdf_name;
$creport->ExportOptions->FormatType = 31;
$creport->ExportOptions->DestinationType = 1;
$creport->Export(false);
$crapp = null;
$creport = null;
$ObjectFactory = null;
if (file_exists($this->pdf_name)) {
echo "true";
/*$pdf = file_get_contents($this->pdf_name);
if(strlen($pdf) != filesize($this->pdf_name))
return "Error: filesize=".filesize($this->pdf_name)." strlen=".strlen($pdf);
header("Pragma: ");
header("Cache-Control: ");
header("Content-type: application/pdf");
//header("Content-Disposition: attachment;filename=" . extractName($this->rpt_name) . ".pdf"); // For IE
header("Content-Disposition: attachment;filename=localhost/assets/pdf/company.pdf"); // For IE
echo($pdf);
exit();*/
} else {
echo "Failed to export";
}
} catch (Exception $e) {
echo "Failed to connect to Crystal Reports 2008: {$e}";
}
}
示例2: COM
<?php
set_time_limit(0);
//if(isset($_GET['id']))
//{
//$id = $_GET['id'];
//} else {
//die('Please specify an ID');
//}
$path = "D:\\MYrep";
//$file = $chemin."\\bill_".$id.".pdf";
$app_obj = new COM("CrystalRuntime.Application") or die("Did not open");
$report = $path . "\\1234.rpt";
$rpt_obj = $app_obj->OpenReport($report, 1);
$app_obj->LogOnServer("p2ssql.dll", "host", "bdd", "userbd", "passwordbd");
$rpt_obj->EnableParameterPrompting = FALSE;
$rpt_obj->RecordSelectionFormula = "{F_DOCLIGNE.DO_Piece}='{$id}'";
$rpt_obj->ExportOptions->DiskFileName = $file;
$rpt_obj->ExportOptions->PDFExportAllPages = true;
$rpt_obj->ExportOptions->DestinationType = 1;
$rpt_obj->ExportOptions->FormatType = 31;
$rpt_obj->Export(false);
header("Content-Type: application/pdf");
readfile($file);