|
 |
|
เขียน php ให้พิมพ์ Report โดยใช้ Crystal Report ไม่รู้ว่าจะเริ่มต้นยังไงดี |
|
 |
|
|
 |
 |
|
ปกติ php ใช้ผ่าน function ของ COM ครับ
|
 |
 |
 |
 |
Date :
2011-07-05 11:34:23 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วผมจะต้องเริ่มยังไงครับ ไปไม่ถูกเลยตอนนี้
|
 |
 |
 |
 |
Date :
2011-07-05 13:17:32 |
By :
suaingam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าเขียนแบบนี้ใช้ได้มั้ยครับ
<?php
$crapp = new COM ("CrystalRuntime.Application") or die ("Error on load");
$creport = $crapp->OpenReport("c:/test.rpt", 1);
$creport->ExportOptions->DiskFileName="c:/test.rtf";
$creport->ExportOptions->DestinationType=1; // Export to File
$creport->ExportOptions->FormatType=4; // Type: RTF
$creport->DiscardSavedData();
$creport->Export(false);
$creport = null;
$crapp = null;
print "...done";
?>
แล้วจะต้องลงโปรแกรมอะไรอีกรึเปล่า
ตอนนี้เครื่องมี Crystal Report ที่มาพร้อมกับ vb 2008 ใช้ได้มั้ยอะครับ
|
 |
 |
 |
 |
Date :
2011-07-05 13:58:09 |
By :
suaingam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ crystal report ติดต่อกับ odbc สิ
ชื่อ mysql-connector-odbc-5.1.5-win32

|
 |
 |
 |
 |
Date :
2011-07-05 14:10:38 |
By :
pumhonda |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
// Create an Crystal Object Factory.
$o_CrObjectFactory = new COM('CrystalReports11.ObjectFactory.1');
// Create the Crystal Reports Runtime Application.
$o_CrApplication =
$o_CrObjectFactory->CreateObject("CrystalRunTime.Application.11");
// Register the typelibrary.
com_load_typelib('CrystalDesignRunTime.Application');
// Load the report.
$o_CrReport = $o_CrApplication->OpenReport('C:\Report.rpt', 1); // 1
== crOpenReportByTempCopy.
// Logon to the database.
$o_CrReport->Database->LogOnServer
(
'odbc',
'Accounts',
registryDatabaseLocations::Database('Accounts'),
registryDatabaseLocations::Username('Accounts'),
registryDatabaseLocations::Password('Accounts')
);
// Don't tell anyone what is going on when running live.
$o_CrReport->DisplayProgressDialog = False;
$s_ExportedReport = 'C:\Report.pdf';
// Run the report and save the PDF to disk.
$o_CrReport->ExportOptions->DiskFileName = $s_ExportedReport;
$o_CrReport->ExportOptions->PDFExportAllPages = True;
$o_CrReport->ExportOptions->DestinationType = 1; // Export to File
$o_CrReport->ExportOptions->FormatType = 31; // 31 = PDF, 36 = XLS, 14 =
DOC
// Assign the parameters to the report.
$m_Stuff = new Variant();
$o_CrPeriodsParam =
$o_CrReport->ParameterFields->GetItemByName('PeriodIDs', $m_Stuff);
$o_CrPeriodsParam->ClearCurrentValueAndRange();
foreach($_SESSION['tabRG_PeriodIDs'] as $i_Period)
{
$o_CrPeriodsParam->AddCurrentValue(intval($i_Period));
}
$o_CrReport->ReadRecords();
$o_CrReport->Export(False);
?>
Go to : พอจะมีบทความเกี่ยวกับ php ติดต่อกับ Crystal Report ไหมครับ
|
 |
 |
 |
 |
Date :
2011-09-25 08:42:01 |
By :
thaicreate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|