Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > พอจะมีบทความเกี่ยวกับ php ติดต่อกับ Crystal Report ไหมครับ



 

พอจะมีบทความเกี่ยวกับ php ติดต่อกับ Crystal Report ไหมครับ

 



Topic : 029420



โพสกระทู้ ( 830 )
บทความ ( 0 )



สถานะออฟไลน์




ตามหัวข้อเลย


หาตามเน็ต ไม่ค่อยเจอ พอเจอแล้ว ยังงงๆ อยู่ 555+



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-07-22 11:37:27 By : danya View : 7061 Reply : 8
 

 

No. 1



โพสกระทู้ ( 483 )
บทความ ( 0 )



สถานะออฟไลน์


http://us2.php.net/manual/en/ref.com.php
เกี่ยวกับ Object COM

ตัวอย่าง Copy มาครับ ไม่รู้ช่วยได้ป่าว

Code (PHP)
$report_source = "";
$report_output = "";
$crapp = new COM ("CrystalRuntime.Application") or die ("Error onload");
$creport = $crapp->OpenReport($report_source, 1);
$creport->EnableParameterPrompting = 0;
$zz= $creport->ParameterFields(1)->SetCurrentValue("Demo"); //เซตค่าให้ Parameter
$creport->ExportOptions->DiskFileName=$report_output";
$creport->ExportOptions->DestinationType=1; // Export to File
$creport->ExportOptions->FormatType=31; // Type: PDF
//$creport->DiscardSavedData(); ต้อง Comment ตัวนี้ไว้ถ้าส่ง Parameter มาด้วย
$creport->Export(false);
$creport = null;
$crapp = null;







Date : 2009-07-22 12:09:19 By : taobsd
 


 

No. 2



โพสกระทู้ ( 830 )
บทความ ( 0 )



สถานะออฟไลน์


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);
?>



------



Guys, I found a way to pass parameters from PHP to Crystal Reports 11 without hanging!!!!

So the problem is the prompt for params dialog:

Code (PHP)
<?php

$ObjectFactory= New COM("CrystalReports11.ObjectFactory.1");
  $crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");
  $creport = $crapp->OpenReport($my_report, 1);
 
 
     
$creport->Database->Tables->
Item(1)->ConnectionProperties['User ID'] =  'blablabla';

$creport->Database->Tables->
Item(1)->ConnectionProperties['Password'] = 'blablabla';

$creport->FormulaSyntax = 0;
$creport->RecordSelectionFormula= "{TABLENAME.FIELDNAME}='$USRID'";

//This is it, this avoids the hanging!
$creport->EnableParameterPrompting = 0;

$creport->DiscardSavedData;
$creport->ReadRecords();

//it is essential to assign the param values here after the readrecords otherwise you will not pass anything...

$zz= $creport->ParameterFields(1)->SetCurrentValue(500);
 
 $creport->ExportOptions->DiskFileName=$exp_pdf;
  $creport->ExportOptions->PDFExportAllPages=true;
  $creport->ExportOptions->DestinationType=1;   $creport->ExportOptions->FormatType=31;
  $creport->Export(false);

$creport->ExportOptions->DiskFileName=$exp_xls;
  $creport->ExportOptions->PDFExportAllPages=true;
  $creport->ExportOptions->DestinationType=1;   $creport->ExportOptions->FormatType=29;
  $creport->Export(false);

$len = filesize($exp_pdf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=reportin.pdf");
readfile("reportin.pdf");

//------ Release the variables
$creport = null;
$crapp = null;
$ObjectFactory = null;

?>



-----




Have fun,
Andras

This function converts the crystal report in file $my_report to a PDF file $my_pdf. Exceptions may raise, so put it in a try..catch block.

I struggled so hard to get this done... any comments, please contact me.

Code (PHP)
<?php
function exportCrystalReportToPDF( $my_report, $my_pdf )
{
  // by dfcp/mar/06
  $ObjectFactory= New COM("CrystalReports11.ObjectFactory.1");
  $crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");
  $creport = $crapp->OpenReport($my_report, 1);

  $creport->ExportOptions->DiskFileName=$my_pdf;
  $creport->ExportOptions->PDFExportAllPages=true;
  $creport->ExportOptions->DestinationType=1; // Export to File
  $creport->ExportOptions->FormatType=31; // Type: PDF
  $creport->Export(false);
}
?>

Date : 2009-07-22 13:41:52 By : danya
 

 

No. 3



โพสกระทู้ ( 830 )
บทความ ( 0 )



สถานะออฟไลน์


ท่องตามเน้ตไปทั่วอะ
Date : 2009-07-22 13:42:29 By : danya
 


 

No. 4



โพสกระทู้ ( 2,794 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ภาษาอังกฤษทั้งนั้น อ่านบ่ออก
ถ้าทำได้ แนะนำมั่งนะครับ
Date : 2009-07-22 14:04:49 By : panyapol
 


 

No. 5



โพสกระทู้ ( 315 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ผมก็กำลังหาเหมือนคุณ ดุ้นยาว เอ้ย ดุนยา เหมือนกันครับ อิอิ
Date : 2012-11-02 14:07:32 By : nerobenz
 


 

No. 6

Guest



Date : 2013-06-11 15:24:33 By : tt
 


 

No. 7



โพสกระทู้ ( 48 )
บทความ ( 0 )



สถานะออฟไลน์


มีใครทำได้บ้างไหมครับ หาจนงงไปหมดแล้วครับ
Date : 2014-07-02 13:50:44 By : aobbie_p
 


 

No. 8



โพสกระทู้ ( 86 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ผมมีทางเลือกอื่นให้
Basic -> dompdf สร้างแทก HTML แล้วจับยัดได้เลย
Expert -> Fpdf ต้องมานั่งตีตารางกำหนดจุดการพิมพ์ด้วยตัวเอง
Date : 2014-07-02 13:54:50 By : soghband
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : พอจะมีบทความเกี่ยวกับ php ติดต่อกับ Crystal Report ไหมครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่