Hi,
I try to load XML files, who contains data, in my report. In the first time, I make my report in Crystal Report XI R2, and connect database with XML File. Then I try this code :
ReportDocument rapport = newReportDocument();
rapport.Load(@"C:\\tmp\\Crystal\\test.rpt");
rapport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, resPath);
Next, I try to load directly my XML file :
ReportDocument rapport = newReportDocument();
rapport.Load(rptPath);
DataSet reportData = newDataSet();
reportData.ReadXmlSchema(@"C:\\tmp\\Crystal\\test.xsd");
reportData.ReadXml(@"C:\\tmp\\Crystal\\test.xml");
rapport.SetDataSource(reportData);
But I've 1 or more XML files of data, and I have a exception :
And to finish, I try to change the path of my XML files in the report :
ReportDocument crystal = newReportDocument();
crystal.Load(@"C:\\tmp\\Crystal\\test.rpt");
var tables = crystal.Database.Tables;
for (int i = 0; i < tables.Count; i++)
{
var table = tables[i];
var nomTable = table.Name;
Char delimiter = '/';
if (nomTable.Split(delimiter).Length > 1)
{
nomTable = nomTable.Split(delimiter)[1];
}
var info = table.LogOnInfo;
var cInfo = info.ConnectionInfo;
cInfo.ServerName = exportPath + "test_" + nomTable + ".xml";
cInfo.DatabaseName = exportPath + "test.xsd";
info.ConnectionInfo = cInfo;
table.ApplyLogOnInfo(info);
}
crystal.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, resPath);
And I've once again a exception :
Please, have you got any other solutions or samples to load XML file's data in a report ?
Thanks.
Matthieu