LocalReport object and XML data


  • Hi,
    I want to create a LocalReport object in code and let it create a report in Excel with an RDL file as report definition and an XMLDocument object as data input. The report was designed with an XML datasource. DesignTime this works well, the XML datasource is pointing to a XML file and the report is rendered in the preview tab no problem.

    But run-time it doesn't work (yet). I don't know how to load the xmlDocument in the LocalReport object. I don't think converting it to a DataSet is going to work. The XML structure has lot of nested nodes. In the RDL file, the design of the report, a custom Dataset is used, based on queries on the XML data source: 

    <DataSet Name="ClientData">
    <Fields><Field Name="name"><DataField>name</DataField><rd:TypeName>System.String</rd:TypeName></Field>
    <Field Name="wwId"><DataField>wwId</DataField><rd:TypeName>System.String</rd:TypeName></Field></Fields>

    <Query><DataSourceName>AssessmentData</DataSourceName><CommandText>Data{} /Plugin{}/assessments/client</CommandText></Query></DataSet>

    So what I want to do is runtime set the datasource to an xmldocument, something like:

    XmlDocument data = new XmlDocument()

    //code to load data in XmlDocument

    LocalReport report = new LocalReport();

    new ReportDataSource("AssessmentData", data));


    byte[] result = report.Render("Excel", deviceInfo, out mimeType, out encoding, out fileExtension, out streams, out warnings);

    But this doesn't work, the error message is:
    A data source instance has not been supplied for the data source "ReportData". (which is one of the datasets that design time is filled by a query on the XML data source)

    So it looks like wat is happening is that runtime the XML data is not translated to Datasets. This does work design time, the datasets are filled with the queries specified in the report definition. Does this not work the same run-time? I could of course create the datasets in code and pass data to the report as data tables. But then I would do work outside the report that is already defined inside the report (the queries). Is there another way of doing this?


    Thursday, September 11, 2008 3:19 PM