Export to XML

4 posts, 0 answers
  1. ethan
    ethan avatar
    9 posts
    Member since:
    Jan 2011

    Posted 28 Jan 2011 Link to this post

    Hi! Is there a sample that adds Export to XML from the report export menu? Thanks.
  2. Peter
    Peter avatar
    1611 posts

    Posted 01 Feb 2011 Link to this post

    Hello ethan,

    Currently there is no out of the box solution for this inquiry. Although there is almost no information on the matter, it is possible to create your own rendering extensions and plug it into the reporting engine. 

    Attached you may find a sample WinDemo project that contains a sample implementation of custom rendering extension that renders the report in XML as by your request.

    As far as the implementation is concerned the most interesting parts are:

    • The XmlRenderingExtension is the actual rendering extension that does the work on transforming the processing report into a XML. Please note how the createStreamCallback is used for the extension to ask the reporting engine for a storage for the generated document;
    • Once you have the XmlTextWriter, the only thing left is to traverse the processing report items' and create the appropriate XML nodes;
    • The app.config contains the registration of our custom rendering extension so the reporting engine can use it. For more information please see Configuring Telerik Reporting.
    As you can see the implementation is quite straightforward and although there is no documentation or other information on the matter I would suggest you to give it a try.

    All the best,
    the Telerik team
    Get started with Telerik Reporting with numerous videos and detailed documentation.
  3. DevCraft R3 2016 release webinar banner
  4. Jayson
    Jayson avatar
    3 posts
    Member since:
    Jun 2015

    Posted 30 Jun 2015 Link to this post

    Hi, I integrate the sample above (XML-RenderingExtensioWinDemo.zip) into telerik sample project - CSharp.Html5Demo.

    Using xml export on html 5 report viewer gave me this error:

    {"message":"An error has occurred.","exceptionMessage":"Buffer cannot be null.\r\nParameter name: buffer","exceptionType":"System.ArgumentNullException","stackTrace":" at System.IO.MemoryStream..ctor(Byte[] buffer, Boolean writable)\r\n at System.IO.MemoryStream..ctor(Byte[] buffer)\r\n at Telerik.Reporting.Services.WebApi.ReportsControllerBase.GetDocument(String clientID, String instanceID, String documentID)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"}

    I only added the extension class and the web.config entry for the extension.

     (I tested the extension on web form report viewer. It works fine.)

    Please help.

  5. Nasko
    Nasko avatar
    909 posts

    Posted 30 Jun 2015 Link to this post

    Hello Jayson,

    The sample solution needs a check which allows the rendering extension to indicate that there is no additional content to be added to the stream. You can modify the XmlRenderingExtension class from the sample solution as shown in the following code snippet:
    public class XmlRenderingExtension : Telerik.Reporting.Processing.IRenderingExtension
        public bool Render(Telerik.Reporting.Processing.Report report
            , System.Collections.Hashtable renderingContext
            , System.Collections.Hashtable deviceInfo
            , Telerik.Reporting.Processing.CreateStream createStreamCallback
            , Telerik.Reporting.Processing.EvaluateHeaderFooterExpressions evalHeaderFooterCallback)
            var stream = createStreamCallback("report/xml", "xml", Encoding.UTF8, "application/xml");
            using (var xmlWriter = new XmlTextWriter(stream, Encoding.UTF8))
                new XmlReportWriter(xmlWriter).Write(report);
            var renderingStream = stream as IRenderStream;
            if(null != renderingStream)
            return true;
        void Telerik.Reporting.IExtension.Initialize(System.Collections.Hashtable deviceInfo)
        public void Dispose()

    Please find attached a sample solution with the HTML5 Report Viewer implementation and the custom XML export option.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top