Telerik Forums
Reporting Forum
1 answer
91 views
I am trying to render a report as an image in my web service and return a byte[] to my client. The byte[] is then converted back into an image for display in the browser. From my debug sessions, I can see that byte[] does have data in it and the view appears to have a correctly sized image; however, the image is completely blank.

This report in particular requires one Integer parameter, ArgID, to be passed in. Blank values can not be accepted. Below is the code I am using (function names and arguments have been modified for brevity).

Web-Service code to render the report as an image:
public byte[] GetReport(int ArgID)
{
    try
    {
        Telerik.Reporting.Processing.ReportProcessor proc = new Telerik.Reporting.Processing.ReportProcessor();
        Telerik.Reporting.InstanceReportSource irs = new Telerik.Reporting.InstanceReportSource();
  
        Report1 report = new Report1();
        report.ReportParameters.Add(new Telerik.Reporting.ReportParameter("ArgID", Telerik.Reporting.ReportParameterType.Integer, ArgID));
        irs.ReportDocument = report;
  
        RenderingResult item = proc.RenderReport("IMAGE", irs, null);
        return item.DocumentBytes;
    }
    catch (Exception ex)
    {
        throw new FaultException(new FaultReason(ex.ToString()));
    }
}

View file img tag:
@model int
<
img src="@Url.Action("GetReport", "Report", new { ID = Model })" alt="" />

Action called from img tag:
[HttpGet]
public ActionResult GetReport(int ID)
{
    byte[] img;
    using (var client = new MyService.MyServiceClient())
    {
        img = client.GetReport(ID);
    }
    return File(img, "image/tiff");
}


I've only just started using Telerik Reporting over SSRS and would like to make the case for switching to Telerik for a long-term solution if I can manage to get programmatic generation working within specifications. Any and all support is greatly appreciated.

Thank you,
-J
Justis
Top achievements
Rank 1
 answered on 15 Apr 2013
3 answers
329 views
I have a DLL with a report. When I go from design mode to preview in VS the report constructor is executed and it does what's required.

Using the stand-alone designer I import the DLL, and on initial creation the constructor is invoked - twice actually. But from then forward, it's never invoked on preview or at any other time.

I created a Windows Form with a report viewer, set the ReportSource to the TRDX via a URL/file reference. Same thing - ODS is called but the report constructor is never invoked.

I'm using the ODS only to retrieve design-time schema. At run-time I'm using report parameters to determine what data to return, and the ODS is invoked manually from NeedDataSource. Someone might think I need to set the ODS to null in the constructor. Again, the constructor is not being called.

The stand-alone designer does show my class name "ReportTemplate" in the Property Browser. So I know it found that class. My report has the ODS pre-loaded, and when the designer first opens that ODS is there, obviously coming from execution of the InitializeConstructor() method, executed from my constructor. So On initial creation it finds what it needs in that class.

From the report viewer, the interactive mode does display a text box that was placed for the header. So it seems InitializeComponent() is getting executed for that report, but nothing else. This is very confusing. It's almost like the report base class is getting executed but not my derived class - and once a report is imported, the derived class isn't invoked anymore. Or perhaps I just don't know what setting to check to get it to instantiate my report class at run-time. Maybe it's a namespace issue and at run-time it can't find my report class within my namespace.

Side note: Originally the interactive mode did not display that report header, but going to preview mode it did. My ODS is returning a DataTable with columns defined and no rows. When I changed that to return a single row of null column data, interactive mode started to show the header too - it's like a null DataSource causes one mode to not render anything but it's different in the other mode. I dunno if anyone would call that a bug but it's certainly slightly anomalous behavior.

Thanks.
Peter
Telerik team
 answered on 15 Apr 2013
1 answer
140 views
I just started using telerik reporting and I can't figure out how to get a marker symbol to show up for my line series.

I am using a Graph control with 1 line series. On the series, I have specified MarkerMaxSize, MarkerMinSize, MarkerSize, and MarkerType, but I still don't see these symbols along my line.
Peter
Telerik team
 answered on 15 Apr 2013
3 answers
280 views
Hi team,
I use an object data source in my report and when I check the preview mode I get an error but if I use the report in report viewer in aspx and run the page i don't get any error.

first i want to know how to debug my business method when I use the preview mode in my report to not always have to run my aspx screen to do the debugging process.

second i want why i get this error, kindly find below the details :

my business method is very simple :
 [DataObjectMethod(DataObjectMethodType.Select)]
        public List<CreatedQRCodesCountBEL> GetCreatedQRCodesCount(int SuperAcctID) { //my code } 

in my report i have one report parameter "SuperAcctID" and i just give it a default value no binding to data source:
An error has occurred while processing Report 'rptCreatedQRCodesCount':
An error occurred while invoking data retrieval method.
Try restarting Visual Studio. ------------- InnerException -------------
Exception has been thrown by the target of an invocation. -------------
InnerException ------------- Object reference not set to an instance of an object.

in my aspx code behind i do the below and it is working without the error:

protected void Page_Load(object sender, EventArgs e)  {
        if (!IsPostBack) {
            var objCreatedQRCodesCountReport = new rptCreatedQRCodesCount();
            objCreatedQRCodesCountReport.ReportParameters["SuperAcctID"].Value = SuperAcctID.ToString();
            radrvCreatedQRCodesCount.ReportSource = objCreatedQRCodesCountReport;
        }
    }

I hope you can help me.
Regards,
Mohammed
Squall
Top achievements
Rank 1
 answered on 15 Apr 2013
1 answer
40 views
I'm playing along with TelerikReporting-LearningGuide.pdf.

I've created a class library and am trying to create the Report Viewer app.

It's a Windows Forms app; I had to change from targeting .NET 4 Client to .NET 4 for the Telerik Reporting Q1 2013 controls to display in the Toolbox (I first tried using a Visual-Studio native ReportViewer control, as the tutorial simply says "ReportViewer," and doesn't specify that it means the Telerik ReportViewer.

I added the class library I created previously in the tutorial to my project References.

Anyway, I drop the Telerik ReportViewer on a form, and locate its Report.ReportSource property. It invokes the "Load a Report From ..." dialog that gives me options of URL or file, Type name, Object instance, or XML markup. I tried both "URL or file" and "Type name" but neither of them want to accept the .dll that I already added as a reference.

Of course, that makes sense, because it doesn't make sense I would have to add the class library/.DLL as a project reference AND then choose it as the report. But what *am* I supposed to choose? I searched my hard drive for *.tr* in Windows Explorer, and the only "trdx" files it finds are 9 that come with the Telerik download.

The tutorial is a little long in the tooth (2008), but I couldn't find an updated version of it. Am I missing something because the process has changed, or...???

Peter
Telerik team
 answered on 15 Apr 2013
1 answer
119 views
Hi
 I'm making a report in which i have a table consisting of two columns, let we have ColumnA and ColumnB, the values of ColumnB
are grouped by ColumnA. The report generates a separate cell for every value of ColumnB but I want  all the values of ColumnB that belongs to a particular value of ColumnA to be in one cell, separated by comma. 

I've attached a snapshot of the two columns, and what I'm doing is to put the values of the 2nd column in a single cell separated by comma. Your help would be greatly appreciated and Sorry for my poor english, I hope you understand it.

Thanks
Stef
Telerik team
 answered on 15 Apr 2013
2 answers
399 views
Hi,

I have encountered a little problem and i would be glad to receive some help.
If I create a stored procedure like this:
CREATE PROCEDURE [dbo].[Telerik] (@ID INT)
AS
BEGIN
 
IF(OBJECT_ID('tempdb..#tmp') IS NOT NULL)
BEGIN
    DROP TABLE #tmp
END
 
CREATE TABLE #tmp
(
ID INT
)
 
INSERT INTO #tmp
    SELECT @ID
     
SELECT * FROM #tmp
 
END
GO
 
EXEC [dbo].[Telerik]  229

result will be quite obvious (it is just a sample to show You my problem).

Now, if I use this stored procedure as a data source command in Telerik Report Designer, it will of course show me the right result in window called "Preview Data Source Results"  but as soon as I click "Finish" button it will not display ANY columns in Data Explorer. Same story happens if I use table variable instead of tmp table. Question is, how can I get columns list in Data Explorer if I'm using tmp table or table variables in stored procedure ? Without it, it is a bit difficult to design anything, as every time I have to create procedure with simple select and proper column names, create data source command based on that procedure, and after that I am changing my procedure to "normal" code (column list in data explorer does not change in this situation). 

How can i avoid this ?

All the best,
Mateusz
Mateusz
Top achievements
Rank 1
 answered on 15 Apr 2013
1 answer
101 views
I read that Telerik Reporting does not support nesting of aggregates and I don't know if there is a way to achieve the following:

* I have a report with a list of amounts and currencies. Some amounts are positive and others are negative.
* I have grouped the amounts by currency.
* In the group footer I put two textboxes:
1) textBox1.Value:  =Sum(IIF(Fields.Amount>=0;Fields.Amount;0))
2) textBox2.Value: =Sum(IIF(Fields.Amount<0;-Fields.Amount;0)) * At the very bottom I need to create a hashcode of respective group footer values. a) textBox3.Value: =Sum(textBox1.Value) b) textBox4.Value: =Sum(textBox2.Value) I can't seem to calculate values based on the group footer results however. Am I missing something really simple?
Yours,

Mattias Ã…slund


Peter
Telerik team
 answered on 15 Apr 2013
2 answers
104 views
Hi

We use ReportViewer for report visualization, print and export in a silverlight application.  

Sometime after we save exported file(no matter what format) the control show exception of type "IO.IO_SharingViolationFile" please see the screen attached.

We need to hide this message from end user and show him some styled popup message with user friendly text.

We tried to add try{ }catch{ } block but sometime it helps sometime now.

then we looked at control ViewModel code and discovered here the reason why we can't catch this exception 

Below is the code listing:

    private void Save()
    {
        string documentName;
        bool flag;
        RenderingResult viewerModel = base.ViewerModel.exportResult;
        if (viewerModel != null)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.DefaultExt = viewerModel.Extension;
            SaveFileDialog saveFileDialog1 = saveFileDialog;
            if (Application.Current.HasElevatedPermissions)
            {
                documentName = viewerModel.DocumentName;
            }
            else
            {
                documentName = null;
            }
            saveFileDialog1.DefaultFileName = documentName;
            saveFileDialog.Filter = ReportViewerModel.SaveExportCommandImpl.BuildSaveFileDialogFilter(base.ViewerModel.selectedExtensionInfo, viewerModel.Extension, base.ViewerModel.TextResources.AllFiles);
            saveFileDialog.FilterIndex = 1;
            SaveFileDialog saveFileDialog2 = saveFileDialog;
            bool? nullable = saveFileDialog2.ShowDialog();
            flag = (!nullable.GetValueOrDefault() ? false : nullable.HasValue);
            if (flag)
            {
                try
                {
                    Stream stream = saveFileDialog2.OpenFile();
                    using (stream)
                    {
                        byte[] documentBytes = viewerModel.DocumentBytes;
                        stream.Write(documentBytes, 0, (int)documentBytes.Length);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    MessageBox.Show(exception.Message);
                }
            }
            return;
        }
        else
        {
            throw new InvalidOperationException(base.ViewerModel.TextResources.UnableToExportError);
        }
    }

Please pay attention on this block 
  try
                {
                    Stream stream = saveFileDialog2.OpenFile();
                    using (stream)
                    {
                        byte[] documentBytes = viewerModel.DocumentBytes;
                        stream.Write(documentBytes, 0, (int)documentBytes.Length);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    MessageBox.Show(exception.Message);
                }

There is standard MessageBox shown and no exception is throw. It make impossible to work with such type of exeptions please fix it


Alexander
Top achievements
Rank 1
 answered on 13 Apr 2013
5 answers
1.2K+ views
I have a report with a table in it.  The table has four columns I know at design time, but there are a unknown number of dynamic columns that I want to display at run time to the right of the four design time/static columns.  Basically I am trying to replicate a Gantt chart and the first four columns are task names and key dates and the dynamic columns are the days I am going to eventually fill in with a background color if the task lands on the dynamic column representing the day.

I have found a couple samples in the forums for creating dynamic columns, but in all of the examples I get the following exception when I try to apply it to my code.

[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Reporting.Processing.Table.CalculateColumns() +328
   Telerik.Reporting.Processing.Table.Measure(MeasureDirection dir, Graphics graphics) +786
   Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics) +181
   Telerik.Reporting.Processing.ProcessingElement.Measure(MeasureDirection dir, Graphics graphics) +1509
   Telerik.Reporting.Processing.ReportSectionBase.Measure(MeasureDirection dir, Graphics graphics) +48
   Telerik.Reporting.Processing.ProcessingElement.MeasureElement(MeasureDirection dir, Graphics graphics) +181
   Telerik.Reporting.Processing.Group.MeasureElement(MeasureDirection dir, Graphics graphics) +286
   Telerik.Reporting.Processing.Report.MeasureElement(MeasureDirection dir, Graphics graphics) +471
   Telerik.Reporting.Processing.Report.MeasureElement(ProcessingElement elementToMeasure) +220
   Telerik.Reporting.Processing.Report.OnItemProcessed() +79
   Telerik.Reporting.Processing.ReportItemBase.Process(DataMember data) +823
   Telerik.Reporting.Processing.Report.Process(DataMember data, DataItemState state, Boolean interactivityEnabled, Boolean documentMapEnabled) +124
   Telerik.Reporting.Processing.ReportProcessor.ProcessReport(IReportDocument reportDocument, IDictionary processingContext) +1313
   Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback) +579
   Telerik.Reporting.Processing.ReportProcessor.RenderReportStateless(String format, IReportDocument reportDocument, Hashtable deviceInfo, Hashtable renderingContext, CreateStream createStreamCallback) +94
   Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo) +195
   TaskReportPage.ExportToPDF(Report reportToExport) in c:\SourceControl\Phenomblue\Websites\WorkamajigAPI\Website\TaskReportPage.aspx.cs:105
   TaskReportPage.btnGenerateGanttReport_Click(Object sender, EventArgs e) in c:\SourceControl\Phenomblue\Websites\WorkamajigAPI\Website\TaskReportPage.aspx.cs:99
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563


Below is report code that is generating the above error.

namespace SOW.Reports
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Linq;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;
    using SOW.DataAccess;
 
    public partial class GanttReport : Telerik.Reporting.Report
    {
        SOWEntities sowContext = null;
 
        public GanttReport(int projectKey)
        {
            InitializeComponent();
 
            sowContext = new SOWEntities();
 
            vListing_Project project = sowContext.vListing_Project.FirstOrDefault(x => x.ProjectKey == projectKey);
 
            /******************** Task Report **********************/
            var tasks = (from task in sowContext.pvTaskReports
                         where task.ProjectKey == projectKey
                         select new
                         {
                             task.Task_Level,
                             task.Task_Name,
                             task.Task_ID,
                             task.Task_Days,
                             task.Plan_Start_Date,
                             task.Plan_Completion_Date,
                             task.Track_Schedules,
                             task.Task_Line_Number,
                             task.Task_Type
                         }).ToList();
 
 
            tblTaskDetails.DataSource = tasks;
        }
 
        private void tblTaskDetails_ItemDataBinding(object sender, EventArgs e)
        {
 
            for (int i = 0; i < 10; i++)
            {
                TableGroup tableGroupColumn = new TableGroup();
                tblTaskDetails.ColumnGroups.Add(tableGroupColumn);
                tblTaskDetails.Body.Columns.Add(new TableBodyColumn(Unit.Inch(.2)));
 
                Telerik.Reporting.TextBox textBoxGroup = new Telerik.Reporting.TextBox();
                textBoxGroup.Value = "x" + i.ToString();
                textBoxGroup.Size = new SizeU(Unit.Inch(.2), Unit.Inch(.2));
                tableGroupColumn.ReportItem = textBoxGroup;
                 
 
                Telerik.Reporting.TextBox textBoxTable = new Telerik.Reporting.TextBox();
                textBoxTable.Value = "";
                textBoxTable.Size = new SizeU(Unit.Inch(.2), Unit.Inch(.2));
                tblTaskDetails.Body.SetCellContent(0, i++, textBoxTable);
                tblTaskDetails.Items.AddRange(new ReportItemBase[] { textBoxTable, textBoxGroup });
            }
 
        }
    }
}

If anyone can provide a better example of how to dynamically add columns to a table that already has columns that would be great!
Benin
Top achievements
Rank 1
 answered on 13 Apr 2013
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?