Monday, July 29, 2013

[Telerik Reporting] Export to CSV: First column becomes row values

I am creating a dynamic report based on a report template and the fields selected. When I export to csv, the first column has repeating data (of the first column).

Here's my web.config settings:
<configSections>
    <section name="Telerik.Reporting" type="Telerik.Reporting.Processing.Config.ReportingConfigurationSection, Telerik.Reporting, Version=7.0.13.426, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" allowLocation="true" allowDefinition="Everywhere"/>
  </configSections>

  <Telerik.Reporting>
    <Extensions>
      <Render>
        <Extension name="CSV">
          <Parameters>
            <Parameter name="NoHeader" value="false"/>
            <Parameter name="NoStaticText" value="true"/>
          </Parameters>
        </Extension>
      </Render>
    </Extensions>
  </Telerik.Reporting>

in the ReportTemplate.cs: private void table1_ItemDataBinding(object sender, EventArgs e)
        {
... //for loop - iterate all selected fields
   var textBox = new Telerik.Reporting.TextBox();
                            textBox.Name = colHeader;
                            textBox.Size = new SizeU(Unit.Inch(width), Unit.Inch(0.3));
                            textBox.CanGrow = true;
                            textBox.StyleName = "Data";
                            textBox.Value = "=Fields.[" + strColumn + "]";

...
         }

I don't experience this issue in static reports, I have placed this workaround inside the constructor:
       
       public Contracts()
        {
            InitializeComponent();

            this.textBox8.Name = "Contract Number";
            this.textBox9.Name = "Date Contract Received";
            this.textBox10.Name = "Deadline Date";
            this.textBox11.Name = "Date of Original Contract";
            this.textBox12.Name = "Contract Execution Date";
            this.textBox13.Name = "Contract Effective Date";
            this.textBox14.Name = "Contract Expiration Date";
            //this.table1.ItemDataBinding += new EventHandler(table1_ItemDataBinding);
        }

Here's the output:



Found out that what's causing exported CSV's first column to become row values was the obsolete NavigateToReportAction.Parameters for sorting

I commented that part and voila, that solved the problem.



Header Image doesn't Display on Telerik Report through Silverlight Report Viewer

Problem: The header image doesn't display on Telerik Report when viewed through Silverlight Report Viewer. But when exported, the image is being displayed.

Solution: 
From Telerik Reporting KB Article

PROBLEM
Images, Charts, Barcodes and Shapes are not being displayed in the Silverlight report viewer.

DESCRIPTION
When a report is previewed in the Silverlight report viewer, Images, Charts, Barcodes and Shapes are missing, however they are present when exporting to one of the supported formats.

SOLUTION
The most probable reason is missing resource endpoint for the Telerik Reporting WCF Servicethat is responsible for serving all images: Picturebox, Chart, Shapes and Barcodes. For proper configuration please refer to the Hosting WCF Service in IIS help article. 
The Silverlight report viewer lives entirely on the client side, while the report rendering is performed on the server. The XAML rendering extension (used by Silverlight report viewer)streams images as resources (similar to HTML), so if the resource endpoint is missing in the service configuration, the images would not be served. When exporting, images are embeddedin the export file.


For SSL: See How to: Enable SSL for Telerik Reporting WCF service


Related Forum Thread: Embedded Image Resources not rendering in Silverlight ReportViewer

Next:
* Take a look at the Custom Binding and its use on Silverlight Application and Telerik Reporting WCF Service