PHP - php crystal report

 
Vista:

php crystal report

Publicado por Milton (1 intervención) el 18/10/2013 20:32:16
Hola estoy haciendo reportes con crystal report y php pero al momento de pasar los parametros "fechas" a crystal report me manda un error ya probe muchas obsiones pero no resultan por favor si alguien podria ayudarme.......
//------ Variables ------
$my_report = "C://creporteOTOS.rpt"; //This must be the full path to the file
$my_pdf = "C://reporte.pdf";

//------ Create a new COM Object of Crytal Reports 10 ------
$ObjectFactory= new COM("CrystalReports.ObjectFactory");

//------ Create a instance of library Application -------
$crapp = $ObjectFactory->CreateObject("CrystalDesignRunTime.Application");

//------ Open your rpt file ------
$creport = $crapp->OpenReport($my_report, 1);

//------ Set database logon info ------
$creport->Database->Tables(1)->SetLogOnInfo("******", "******", "****", "*******");

//------ Suppress the Parameter field prompt or else report will hang ------
$creport->EnableParameterPrompting = 0;

//------ DiscardSavedData make a Refresh in your data -------
$creport->DiscardSavedData;
$creport->ReadRecords();

//------ Pass formula fields --------
//$creport->FormulaFields->Item(1)->Text = ("'My reporte milton usca'");
$creport->ParameterFields(1)->AddCurrentValue ('01/04/2013'); //aqui empieza el error
$creport->ParameterFields(2)->AddCurrentValue ('10/04/2013');


// $zz = $creport->ParameterFields(1)->SetCurrentValue( intval( $param, 10) );



//------ Export to PDF -------
$creport->ExportOptions->DiskFileName=$my_pdf;
$creport->ExportOptions->FormatType=31;
$creport->ExportOptions->DestinationType=1;
$creport->Export(false);

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

//------ Embed the report in the webpage ------
print "<embed src=\"MyReport.pdf\" width=\"100%\" height=\"100%\">"



este es el error que me bota :
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> <br/><b>Description:</b> No se puede mover porque el conjunto de filas est&#65533; vac&#65533;o.' in C:\xampp\htdocs\www\helpdesk\contenido\pcr.php:133 Stack trace: #0 C:\xampp\htdocs\www\helpdesk\contenido\pcr.php(133): variant->AddCurrentValue('01/04/2013') #1 {main} thrown in C:\xampp\htdocs\www\helpdesk\contenido\pcr.php on line 133
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

php crystal report

Publicado por Elena (1 intervención) el 13/08/2014 05:18:12
Hola, me presento con el mismo error, haz logrado mostrar el reporte?? como visualizas el reporte tienes instalado crystal reports? ayuda porfavoor!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

php crystal report

Publicado por David Gutierrez (1 intervención) el 14/12/2017 20:25:53
Han pasado años, pero igual es bueno aportar algo por si nunca pudieron resolverlo. De esta manera realizo reportes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
mysql_connect($Host.":".$Puerto,$User,$Password);
mysql_select_db ($Bd);
 
$tipoimpresion = $_GET['tipoimpresion'];
if ($_GET['cveini']!=''){
    $cveini = zerofill($_GET['cveini'],6);
}
if ($_GET['cvefin']!=''){
    $cvefin = zerofill($_GET['cvefin'],6);
}
$fechaini = $_GET['fechaini'];
$fechafin = $_GET['fechafin'];
switch ($tipoimpresion) {
    case 'PDF':
        $extension = 'pdf';
        $destination = 31;
        break;
    case 'EXCEL': //Excel Formato
        $extension = 'xls';
        $destination = 38;
        break;
    case 'EXCELFORMATODATOS':  //Excel Formato Datos
        $extension = 'xls';
        $destination = 36;
        break;
    case 'EXCELDATOS':  //Excel Datos
        $extension = 'xls';
        $destination = 38;
        break;
}
 
$RutaReportes = Configura('RUTAREPORTESCRYSTALREPORTSSLT',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$NombreServidorReportes = Configura('NOMBRESERVIDORRPTCRYSTAL',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$NombreDatabaseReportes = Configura('NOMBREDATABASERPTCRYSTAL',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$NombreUserReportes = Configura('NOMBREUSERRPTCRYSTAL',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$NombrePassReportes = Configura('NOMBREPASSRPTCRYSTAL',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$Agregarlogo        = Configura('AGREGARLOGOENREPORTES',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$PathLogo           = Configura('PATHLOGOENREPORTES',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$Seccionlogo        = Configura('SECCIONLOGOENREPORTES',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$PosicionXLogo      = Configura('POSICIONXLOGOENREPORTES',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$PosicionYLogo      = Configura('POSICIONYLOGOENREPORTES',"","",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
$CARTERAENDOLARES      = Configura('CARTERAENDOLARES',"","0",$Host,$Puerto,$User,$Password,$Bd,$ClienteNumserie,$ClienteClave);
 
$my_report = $RutaReportes."reportsfiles\\$ClienteNumserie\\ROTACIONDIASD.rpt";
if(file_exists($my_report)){ //Verifico si realmente existe, si es True entra y lo toma.
    $my_report = $RutaReportes."reportsfiles\\$ClienteNumserie\\ROTACIONDIASD.rpt";
}else{ //si es False tomara el Generico
    $my_report = $RutaReportes."reportsfiles\\reportesgenericos\\ROTACIONDIASD.rpt";
}
$upload_dir = "../reportsfiles/".$ClienteNumserie."/facturasgral/";
if(!is_dir($upload_dir)){
     @mkdir($upload_dir, 0777,true);
}
$nombrereporte = "";
$nombrereporte = "ROTACIONDIASD.".$extension;
$my_pdf = $RutaReportes."reportsfiles\\".$ClienteNumserie."\\facturasgral\\".$nombrereporte;
$ObjectFactory= new COM("CrystalReports115.ObjectFactory.1");
try {
    $crapp = $ObjectFactory->CreateObject("CrystalRunTime.Application.11");
    echo $my_report;
    $creport = $crapp->OpenReport($my_report, 1);
 
    $canttables = $creport->Database->Tables->Count;
    echo "<br>Tablas:".$canttables;
    for ($i = 1; $i <= $canttables; $i++)
    {
        $oldLocation = $creport->Database->Tables($i)->Location;
        echo "<br>Location:".$oldLocation;
       $creport->Database->Tables($i)->ConnectionProperties->DeleteAll();
       $creport->Database->Tables($i)->ConnectionProperties->Add("Connection String","Driver=MySQL ODBC 5.1 Driver;Server=". $NombreServidorReportes . ";Database=" . $NombreDatabaseReportes . ";UID=". $NombreUserReportes .";PWD=". $NombrePassReportes . ";");
       $newLocation = $NombreDatabaseReportes . "." . $oldLocation;
       echo "<br>New Location:".$newLocation;
       $creport->Database->Tables($i)->Location = $newLocation;
    }
    $creport->EnableParameterPrompting = 0;
    $creport->DiscardSavedData;
    if ($Agregarlogo==1) {
      $my_logo = $RutaReportes.$PathLogo;
      if (file_exists($my_logo)) {
        $creport->Sections((int)$Seccionlogo)->AddPictureObject($my_logo, $PosicionXLogo, $PosicionYLogo);
      }
    }
 
    if($CARTERAENDOLARES == 1 || $CARTERAENDOLARES =="1"){
        $CARTERAENDOLARES = TRUE;
    }else{
        $CARTERAENDOLARES = FALSE;
    }
 
    $creport->ParameterFields(1)->AddCurrentValue("$cveini");
    $creport->ParameterFields(2)->AddCurrentValue("$cvefin");
    $creport->ParameterFields(3)->AddCurrentValue("$fechaini");
    $creport->ParameterFields(4)->AddCurrentValue("$fechafin");
    $creport->ParameterFields(5)->AddCurrentValue($CARTERAENDOLARES);
    $creport->ReadRecords();
    $creport->ExportOptions->DiskFileName=$my_pdf;
    $creport->ExportOptions->FormatType=$destination;
    $creport->ExportOptions->DestinationType=1;
    $creport->Export(false);
    $creport = null;
    $crapp = null;
    $ObjectFactory = null;
 
    $nombre_fichero = $upload_dir.$nombrereporte;
    headerFunction($nombre_fichero);
} catch (com_exception $e){
    echo("<br>Error En Creacion de Instancia:<br>".$e->getMessage().'<p>'.$e->getTraceAsString().'</p>');
    echo "<p><pre>".print_r($e, true)."</pre></p>";
    exit;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar