Bonjour.
J'essaye d'exporter des données extraites à une BD vers un fichier PDF mais ça ne marche pas et j'ai le message d'erreur suivant au moment du lancement de la méthode export() de ReportDocument :
Code :
1 2
|
"Erreur dans le fichier C:\\...\\Fichier.rpt :\nCondition de groupe incorrecte." |
Voici le code :
Code :
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
|
//Declaration d'un Crystal Report
ReportDocument crReportDocument = new ReportDocument();
//chargement du report .rpt
string path = @"C:\...\Fichier.rpt";
crReportDocument.Load(path);
(uniquement pour SQl Server)
TableLogOnInfo logoninfo = new TableLogOnInfo ();
SetDatabaseLogOnInfos(crReportDocument);
//Definition des options relative au report
ExportOptions exportOpts = crReportDocument.ExportOptions;
//Nom du fichier
string sFile = @"C:\ArKdosMediWeb\test.pdf";
//Fichier crée sur le disque
DiskFileDestinationOptions File = new DiskFileDestinationOptions();
File.DiskFileName = sFile;
exportOpts.DestinationOptions = File;
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
//Création du fichier
try
{
crReportDocument.Export();
}
catch (Exception ee)
{
string mes = ee.Message.ToString();
...
} |
Code :
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
|
private static void SetDatabaseLogOnInfos(ReportDocument rptReport)
{
//Parcours des différents sous-états de l’état
foreach(Section sctSection IN rptReport.ReportDefinition.Sections)
{
foreach(ReportObject rpoReportObject IN sctSection.ReportObjects)
{
IF(rpoReportObject.Kind == ReportObjectKind.SubreportObject)
{
SubreportObject sroSubReport = (SubreportObject)rpoReportObject;
SetDatabaseLogOnInfos(sroSubReport.OpenSubreport(sroSubReport.SubreportName));
sroSubReport=NULL;
}
}
}
//Modification des informations de connexion à la source de données
CrystalDecisions.Shared.TableLogOnInfo tliCurrent = new CrystalDecisions.Shared.TableLogOnInfo();
foreach(CrystalDecisions.CrystalReports.Engine.TABLE tblTable IN rptReport.DATABASE.TABLES)
{
tliCurrent = tblTable.LogOnInfo;
tliCurrent.ConnectionInfo.ServerName = @"nomserver2000";
tliCurrent.ConnectionInfo.DatabaseName = "nomBD";
tliCurrent.ConnectionInfo.UserID = "UserBD";
tliCurrent.ConnectionInfo.Password = "pwd";
tblTable.ApplyLogOnInfo(tliCurrent);
tblTable.Location="ArKdos.dbo.MyView";
}
} |
L'erreur se produit lors de l'appel à la méthode export().
Je découvre à peine Crystal Report.
Pourriez vous m'éclairer ?