Telerik Forums
Reporting Forum
2 answers
574 views
Greetings.

I'm not sure how to do this so asking it here. I have a Web API project that I've added the HTML5 ReportViewer.  I have looked at the examples included with Q3 2013 release but they reference a dll, not the trdx file. What I need to do is find the plumbing to:
1) load the trdx file
2) assign the dataset to the report
3) display the report

Simple eh?  But not if you can't find an example.  In the past I was able to do this on a windows form by:
<snippet>
 // reportInfo is a class that has all the report details, header, DataSet, etc
   XDocument doc = LoadXDocument(reportInfo); 

// open the report
 BufferedStream stream = new BufferedStream(new MemoryStream());
 stream.Write(Encoding.ASCII.GetBytes(doc.ToString()), 0, doc.ToString().Length);
 stream.Seek(0, SeekOrigin.Begin);
 StreamReader sr = new StreamReader(stream); 
System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
 settings.IgnoreWhitespace = true; 

XmlDocument xmlDoc = GetXmlDocument(doc);
 Telerik.Reporting.Report report; 

using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(sr, settings))
 {
  Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer = new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();  
report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
 } 

Telerik.Reporting.TextBox tbHeader = (Telerik.Reporting.TextBox)report.Items["pageHeaderSection1"].Items["textBoxHeader"];
 tbHeader.Value = reportInfo.Title; 

if (reportInfo.CompanyLogo != "" && reportInfo.CompanyLogo != null)
 {
  Telerik.Reporting.PictureBox pictureBoxCompanyLogo = (Telerik.Reporting.PictureBox)report.Items["pageHeaderSection1"].Items["pictureboxCompanyLogo"];
  pictureBoxCompanyLogo.MimeType = reportInfo.CompanyLogoExt != "" ? "Image/" + reportInfo.CompanyLogoExt.ToUpper() : "";
  pictureBoxCompanyLogo.Value = Image.FromFile(reportInfo.CompanyLogo);
 } 

foreach (TableInfo tableinfo in reportInfo.Tables)
 {
  Telerik.Reporting.Table table = (Telerik.Reporting.Table)report.Items["detailSection1"].Items[tableinfo.ReportTableName];
  table.DataSource = tableinfo.DataSource;
 }
 
</snippet>    
    
 //routine that converts the XDocument (trdx) into XmlDocument
 private XmlDocument GetXmlDocument(XDocument document)
 {
  using (XmlReader xmlReader = document.CreateReader())
  {
   XmlDocument xmlDoc = new XmlDocument();
   xmlDoc.Load(xmlReader);
   if (document.Declaration != null)
   {
    XmlDeclaration dec = xmlDoc.CreateXmlDeclaration(document.Declaration.Version,
     document.Declaration.Encoding, document.Declaration.Standalone);
    xmlDoc.InsertBefore(dec, xmlDoc.FirstChild);
   }
   return xmlDoc;
  }
 }

oh if anyone wants to use that code, the one thing to point out is your DataTables need to have the same name as your Tables in the trdx else the Table cant assign the data.

I have to say that in the past all the responses the best I've ever gotten was a link to the documentation that only has partial code.  I just wish for once that someone would actually give me what I want, maybe a small web api project that loads a single report (trdx file) based on a datatable using the html5 viewer?
 
References:
http://www.telerik.com/help/reporting/telerik-reporting-rest-host-http-service-using-web-hosting.html
http://www.telerik.com/help/reporting/html5-report-viewer-embedding.html
many many others.....

Background Info
===================================
A lot of this should look familiar since it was basically cut and pasted from what I could find from your docs. 

WebApp (other sections not shown for simplicity)
----------------------------------------------
 Controllers
  ReportsController.cs
 Reports
  Sample1.trdx
 ReportViewer
  all files copied over from ReportViewer Folder and added to web app
 Views
  Reports
   Index.cshtml

ReportsController.cs
--------------------------------------------  
using System.Web;
using Telerik.Reporting.Cache.Interfaces;
using Telerik.Reporting.Services.Engine;
using Telerik.Reporting.Services.WebApi;namespace WebApp.Controllers
{
        public class ReportsController : ReportsControllerBase
    {
        protected override IReportResolver CreateReportResolver()
        {
            var reportsPath = HttpContext.Current.Server.MapPath("~/Reports");            return new ReportFileResolver(reportsPath)
                .AddFallbackResolver(new ReportTypeResolver());
        }        protected override ICache CreateCache()
        {
            return Telerik.Reporting.Services.Engine.CacheFactory.CreateFileCache();
        }
    }
}
   
Index.cshtml
---------------------------------
<head>
    <link href="ReportViewer/styles/ReportViewer-7.2.13.1010.css" rel="stylesheet" />
    <script src="ReportViewer/js/ReportViewer-7.2.13.1010.js"></script>    <style>
        #reportViewer1 {
            /*position: absolute;*/
            left: 5px;
            right: 5px;
            top: 5px;
            bottom: 5px;
            font-family: 'segoe ui', 'ms sans serif';
            overflow: hidden;
        }
    </style></head>
<style>
    ul {
        list-style-type: none;
        padding: 0;
        margin: 0;
    }    table td, table td * {
        vertical-align: top;
    }
</style><h3>Title</h3><table style="padding: 0; margin: 0; border: 1px">
    <tr>
        <td>
            <ul id="panelbar" style="width: 150px; list-style-position: inside; padding: 0; margin: 0">
    /* code omitted */
            </ul>
        </td>
        <td>
            <div id="reportViewer1" class="k-widget">
            </div>
         </td>
    </tr>
</table><script>
    $("#panelbar").kendoPanelBar({
        expandMode: "single"
    });
</script><script type="text/javascript">
    //async
    $(document).ready(function () {
  //code omitted for panelbar        $("#reportViewer1")
            .telerik_ReportViewer({
            serviceUrl: "/api/reports/",
            templateUrl: '/ReportViewer/templates/telerikReportViewerTemplate.htmll',
            reportSource: { report: "~Reports/Sample1.trdx" }
        });
    });
</script>

trdx file
-----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<Report Width="8in" Name="Sample Report 1" xmlns="http://schemas.telerik.com/reporting/2012/3.4">
  <Items>
    <PageHeaderSection Height="0.730000019073486in" Name="pageHeaderSection1">
      <Style>
        <BorderStyle Bottom="Solid" />
        <BorderColor Bottom="0, 61, 121" />
      </Style>
      <Items>
        <PictureBox Width="1.82000005245209in" Height="0.629999995231628in" Left="6.18in" Top="0.1in" Sizing="Stretch" Anchoring="Top, Right" Name="pictureboxCompanyLogo" />
        <TextBox Width="6.07991790771484in" Left="0in" Height="0.5in" Top="0.1in" Value="" TextWrap="True" Anchoring="Top, Left, Right" Name="textBoxHeader">
          <Style Color="0, 61, 121" TextAlign="Left" VerticalAlign="Bottom">
            <Font Name="Microsoft Sans Serif" Size="12pt" Bold="True" />
          </Style>
        </TextBox>
      </Items>
    </PageHeaderSection>
    <DetailSection Height="6in" Name="detailSection1">
      <Items>
        <Table Width="1.59375in" Height="0.61666658787421in" Left="0.00in" Top="0.16in" ColumnHeadersPrintOnEveryPage="True" Name="detailTable_b066f4d8089a4c38993391bc534ce628">
          <Body>
            <Cells>
              <TableCell RowIndex="0" ColumnIndex="0" RowSpan="1" ColumnSpan="1">
                <ReportItem>
                  <TextBox Width="0.927083333333333in" Height="0.18in" CanGrow="True" WordWrap="True" Left="0in" Top="0in" Value="=Fields.[Description]" Name="textBoxDetail_Description">
                    <Style TextAlign="Left" VerticalAlign="Middle">
                      <Font Name="Microsoft Sans Serif" Size="8pt" />
                    </Style>
                    <ConditionalFormatting>
                      <FormattingRule>
                        <Style BackgroundColor="230, 231, 232" />
                        <Filters>
                          <Filter Expression="=RowNumber()%2" Operator="Equal" Value="=1" />
                        </Filters>
                      </FormattingRule>
                    </ConditionalFormatting>
                  </TextBox>
                </ReportItem>
              </TableCell>
              <TableCell RowIndex="0" ColumnIndex="1" RowSpan="1" ColumnSpan="1">
                <ReportItem>
                  <TextBox Width="0.666666666666667in" Height="0.18in" CanGrow="True" WordWrap="True" Left="0in" Top="0in" Value="=Fields.[Value]" Name="textBoxDetail_Value">
                    <Style TextAlign="Right" VerticalAlign="Middle">
                      <Font Name="Microsoft Sans Serif" Size="8pt" />
                    </Style>
                    <ConditionalFormatting>
                      <FormattingRule>
                        <Style BackgroundColor="230, 231, 232" />
                        <Filters>
                          <Filter Expression="=RowNumber()%2" Operator="Equal" Value="=1" />
                        </Filters>
                      </FormattingRule>
                    </ConditionalFormatting>
                  </TextBox>
                </ReportItem>
              </TableCell>
            </Cells>
            <Columns>
              <Column Width="0.927083333333333in" />
              <Column Width="0.666666666666667in" />
            </Columns>
            <Rows>
              <Row Height="0.18in" />
            </Rows>
          </Body>
          <Corner />
          <Style>
            <BorderStyle Default="Solid" />
          </Style>
          <RowGroups>
            <TableGroup Name="detailTableGroup">
              <Groupings>
                <Grouping />
              </Groupings>
            </TableGroup>
          </RowGroups>
          <ColumnGroups>
            <TableGroup Name="tableGroup">
              <ReportItem>
                <TextBox Width="1.59375in" Height="0.2in" Left="0in" Top="0in" Value="" Name="textBoxTableTitle_detailTable_b066f4d8089a4c38993391bc534ce628" StyleName="">
                  <Style BackgroundColor="0, 61, 121" Color="White" VerticalAlign="Middle" Bottom="Solid">
                    <BorderStyle Bottom="Solid" />
                    <BorderColor Bottom="131, 171, 85" />
                    <Font Name="Microsoft Sans Serif" Bold="False" Size="9pt" />
                  </Style>
                </TextBox>
              </ReportItem>
              <ChildGroups>
                <TableGroup Name="groupDescription">
                  <ReportItem>
                    <TextBox Width="0.927083333333333in" Height="0.23in" Left="0in" Top="0in" Value="Description" Name="textBoxRowHeader_Description">
                      <Style BackgroundColor="White" Color="13, 80, 169" VerticalAlign="Bottom" TextAlign="Left">
                        <BorderStyle Bottom="Solid" />
                        <BorderColor Bottom="13, 80, 169" />
                        <Font Name="Microsoft Sans Serif" Size="9pt" Bold="False" />
                        <Padding Bottom="1pt" />
                      </Style>
                    </TextBox>
                  </ReportItem>
                </TableGroup>
                <TableGroup Name="groupValue">
                  <ReportItem>
                    <TextBox Width="0.666666666666667in" Height="0.23in" Left="0in" Top="0in" Value="Value" Name="textBoxRowHeader_Value">
                      <Style BackgroundColor="White" Color="13, 80, 169" VerticalAlign="Bottom" TextAlign="Right">
                        <BorderStyle Bottom="Solid" />
                        <BorderColor Bottom="13, 80, 169" />
                        <Font Name="Microsoft Sans Serif" Size="9pt" Bold="False" />
                        <Padding Bottom="1pt" />
                      </Style>
                    </TextBox>
                  </ReportItem>
                </TableGroup>
              </ChildGroups>
            </TableGroup>
          </ColumnGroups>
        </Table>
        <TextBox Width="2.5in" Height="0.18in" CanGrow="False" Left="0in" Top="0.82666658787421in" Value="* Lower rate indicates better performance" Name="textBoxDetail_a4b1b395d8414d85a3e237623d8289c7">
          <Style Color="Black" TextAlign="Left" VerticleAlign="Middle">
            <Font Name="Microsoft Sans Serif" Size="8pt" Bold="False" Italic="True" />
          </Style>
        </TextBox>
      </Items>
    </DetailSection>
    <PageFooterSection Height="0.769999821980794in" Name="pageFooterSection1">
      <Style>
        <BorderStyle Top="Solid" />
        <BorderColor Top="0, 61, 121" />
      </Style>
      <Items>
        <PictureBox Width="0.8in" Height="0.5in" Left="0.1in" Top="0.15in" Sizing="Stretch" MimeType="image/png" Anchoring="Top, Left" Value="" Name="pictureBox" />
        <TextBox Width="2.69997572898865in" Height=".18in" Left="5.19791666666667in" Top="0.447916030883789in" Value="=&quot;Generated on &quot; + NOW()" Anchoring="Top, Right" Name="currentTimeTextBox" StyleName="PageInfo">
          <Style Color="DimGray" TextAlign="Right" VerticalAlign="Middle">
            <Font Name="Microsoft Sans Serif" Size="9pt" />
          </Style>
        </TextBox>
        <TextBox Width="3.0in" Height="0.2in" Left="2.5in" Top="0.15in" Value="=&quot;Page &quot; + PageNumber + &quot; of &quot; + PageCount" Anchoring="Top, Left" Name="pageInfoTextBox" StyleName="PageInfo">
          <Style Color="13, 80, 169" TextAlign="Center" VerticalAlign="Middle">
            <Font Name="Microsoft Sans Serif" Size="9pt" />
          </Style>
        </TextBox>
      </Items>
    </PageFooterSection>
  </Items>
  <StyleSheet>
    <StyleRule>
      <Style>
        <Padding Left="2pt" Right="2pt" />
      </Style>
      <Selectors>
        <TypeSelector Type="TextItemBase" />
        <TypeSelector Type="HtmlTextBox" />
      </Selectors>
    </StyleRule>
  </StyleSheet>
  <PageSettings>
    <PageSettings PaperKind="Letter" Landscape="False">
      <Margins>
        <MarginsU Left="0.25in" Right="0.25in" Top="0.25in" Bottom="0.25in" />
      </Margins>
    </PageSettings>
  </PageSettings>
</Report>
Glenn
Top achievements
Rank 1
 answered on 16 May 2014
5 answers
144 views
Hi..

My sp returns 3 datatable in a dataset. i put the dataset in loop and creates dynamic table

 for (int m = 1; m < dataSet.Tables.Count - 1; m++)
{
  Table table1 = new Table();
        DataTable data = dataSet.Tables[m];
       
...................................
       
-----------------------------------
        Panel pnlPeerReviewerRecommendation = new Panel();
        pnlPeerReviewerRecommendation.Anchoring = AnchoringStyles.Left;
       
table1.Anchoring = AnchoringStyles.Left;
       
table1.Top = new Unit(20.0d);
       
pnlPeerReviewerRecommendation.Items.Add(table1);
 
}


and i'm adding this panel to another panel which i cretated in the desiger.

My issue is the tables are binding in the reverse order.

Thats is the the last table in the dataset shows first. please help me..


Thanks,
Mahesh
Stef
Telerik team
 answered on 16 May 2014
4 answers
137 views
Hi,

I have been waiting for this feature to be integrated in the Reporting suite for years now. I was wondering if the team has considered a feature for generating reports from client-side data in Silverlight as my application do not use server data? I need to generate report from the user input. Do you have this feature now and its just that I am unaware of it?

I really do not want to have to buy the whole suite from another vendor just for this feature as everything else Telerik intregrates nicely into my app.

Cheers!
Stef
Telerik team
 answered on 16 May 2014
1 answer
89 views
I am including the Telerik Data Access DLL's with my VS project that is using the Reporting tool, we are not even referencing the data access DLL's,  however, each time I deploy the code to a client machine, I get an error that the Data Access DLL's are not found. Only after I download and install the data access does the error go away. Can anyone tell me what is being set when I install data access that is not being done when I deploy my code. I have already read the the link below

http://www.telerik.com/support/kb/data-access/details/handling-error-could-not-load-file-or-assembly-telerik-openaccess-or-one-of-its-dependencies

that deals with this subject but I am still having issues. Can anyone help? What needs to be in my project so I dont get this error?
Hinata
Top achievements
Rank 1
 answered on 16 May 2014
1 answer
136 views
Hi,
I am having an issue exporting to CSV. I have a Report where Reports Items have Sub-Reports.  when i exported to CSV i got dulicate values.same data can be see over and over,some of the data do not match with the original.
Other exportings are working fine....


Is there any suggestions or work-arounds to get for a solution Please give a reply..

Regards
Manu vijayan
Stef
Telerik team
 answered on 16 May 2014
1 answer
141 views
I have a Telerik Report to produce monthly invoices. When I run the invoices into a Telerik Report Viewer, it works great.

If I use the same Report with RenderReport to run the invoices into a PDF document to
be emailed, the PDF consists of the report's header logo, and the footer
datetime and page number. The center section (retrieved from the
database) is blank. I'm not sure what I'm doing wrong. I've verified
that the parameters passed are correct and the same as the ones passed
into the Report Viewer. Any help would be appreciated.


private string SendOutInvoiceEmails(DateTime dtStartDate, Int16 intFinalInvoice, Int16 intFacility)
{
var typeReportSource = new Telerik.Reporting.TypeReportSource();
typeReportSource.TypeName = "TelerikReports.InvoiceMaster, TelerikReports";
typeReportSource.Parameters.Add("RID", rdr["Resid"]);
typeReportSource.Parameters.Add("RDM", dtStartDate.Month);
typeReportSource.Parameters.Add("RDY", dtStartDate.Year);

MailReport(typeReportSource, "admin@rexxrally.com", recRes.email_address, "Monthly Invoice For " + dtStartDate.ToString("MMM") + ", " + dtStartDate.ToString("yyyy"), "Here is your monthly invoice.", rdr["resid"].ToString());
}


void MailReport(Telerik.Reporting.ReportSource rptSource,
string from,
string to,
string subject,
string body,
string ResID)
{
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", rptSource, null);
MemoryStream ms = new MemoryStream(result.DocumentBytes);
ms.Position = 0;
Attachment attachment = new Attachment(ms, "Invoice" + ResID + ".pdf");

MailMessage msg = new MailMessage(from, to, subject, body);
msg.Attachments.Add(attachment);

SmtpClient smptClient = new SmtpClient();
smptClient.Credentials = CredentialCache.DefaultNetworkCredentials;

smptClient.Send(msg);
}
Dave
Top achievements
Rank 1
 answered on 15 May 2014
9 answers
144 views
Is it possible to off-load the Report Processing to a client-side Silverlight application, instead of processing the Report Definition and Data on the server side to produce the Report Instance?

-Paul
Mike
Top achievements
Rank 1
 answered on 15 May 2014
5 answers
326 views

Hello again,

could it be that the TElerik Reporting Html 5 Service is not compatible to the current Microsoft.WebAPI (5.0)?
- I created an empty Asp.net Application (WebForms) in VS2013,
- added the Telerik.Reporting dlls via filesystem
- and the Microsoft.WebAPI via nuget.
- configure the reporting routes in the global.asax /APP_START:
ReportsControllerConfiguration.RegisterRoutes(System.Web.Http.GlobalConfiguration.Configuration);
- Start the WebApp

The application throws an exception:

Die Datei oder Assembly "System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)

The same problem arises when using the default visual studio webforms template which includes/defaults to the current Microsoft.AspNet.WebAPI (5.0)

I tried to download the latest internal build but the link (
http://www.telerik.com/downloads/nightbuildfiles/dkkm/Telerik_Reporting_Q3_2013_7.2.13.1105_DEV.msi)

only points to a moved resource which redirects to the  accounts/download.aspx

To reproduce the problem just follow the steps above in a VS2013 instance

THank you for your assistance.
Regards,
Kris


Yegor
Top achievements
Rank 1
 answered on 15 May 2014
2 answers
63 views
Hi,
I am considering buying your reporting package, to html5 project in durandal.
I wanted to ask a few questions: 
1. I installed the trial version and tried to add your report to my project, and in the add report wizard in choosing data source I do not accept the types to choose from, its just empty window . What could be the problem? 

2. Can I link the data source for dynamic connection string / comes in the configuration? 

3. I tried to print a report of your sample project in html5 demo but instead printing is performed , pdf file Download.
What could be the reason for this? Have defined a default printer on the computer - control panel, but it did not help. 

4.Whether you can edit the  sql query- select sentence at runtime (by user search/filter/order.. on Client)?

I would be happy if you answer me as soon as possible,

It is urgent to me to decide whether your financial tool answer my needs,

Thank you!
Nasko
Telerik team
 answered on 14 May 2014
2 answers
325 views
Hi,

I'm with this problem in a report that I am unable to solve the problem 

I have these command gives the error and where this is 



protected void Form1_LoadCompleted_1()
{
try
            {
                System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
                settings.IgnoreWhitespace = true;
                System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(this.MapPath("Rel_proposta_teste.trdx"), settings);


                Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer = new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
                Telerik.Reporting.Report report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
                Rel.SetReportConnectionString(report, Convert.ToString(((Databases)Application["Databases"]).DataBaseList["Bdescala"].StringConnection)); <<<here problem>>>
                report.ReportParameters["Param_idproposta"].Value = Param_idproposta_inicio;


                // Atenção = altere o parâmetro “pld_entidade” para o parâmetro que vc criou no Reporting Telerik. 

                this.ReportViewer1.ReportSource = new Telerik.Reporting.InstanceReportSource
               {
                   ReportDocument = report,
               };

            }
            catch (Exception ex)
            {
                labError.Text = ex.Message.ToString();
            }
}


public partial class Rel : System.Web.UI.Page
{

public static void SetReportConnectionString(Telerik.Reporting.Report reportDocument, String connectionString)
        {
            Telerik.Reporting.SqlDataSource sds = (Telerik.Reporting.SqlDataSource)reportDocument.DataSource;
            if (sds != null)
                sds.ConnectionString = connectionString;
            SetReportConnectionString(reportDocument.Items, connectionString);
        }
        public static void SetReportConnectionString(Telerik.Reporting.ReportItemBase.ItemCollection items, String connectionString)
        {
            foreach (Telerik.Reporting.ReportItemBase ib in items)
            {
                if (ib.Items != null)
                {
                    SetReportConnectionString(ib.Items, connectionString);
                }
                Type type = ib.GetType();
                System.Reflection.PropertyInfo dataSourceProperty = type.GetProperty("DataSource");
                if (dataSourceProperty == null)
                    continue;
                var dataSource = dataSourceProperty.GetValue(ib, null) as Telerik.Reporting.SqlDataSource;
                dataSource.ConnectionString = connectionString;
            }
        }

}

The report is attached

thank you

NIgri
KS
Top achievements
Rank 1
 answered on 14 May 2014
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?