Telerik Forums
Reporting Forum
5 answers
128 views

Hello,
with the latest production release.

  1. Create a new report.
  2. Drag a Table to the details section.
  3. Drag a Panel to a cell of the table

Error message:

Object reference not set to an instance of an object.

Stef
Telerik team
 answered on 15 Feb 2016
1 answer
105 views

I have a site that allows users to upload images to the report. The users can upload as many images as they want and the images get appended to the report.

The report viewer initially contains a report and the users images are appended at the button of the report. The way I append the images: I have created a one page report that has an image in the middle of the report. I iterate through all the image paths and add a new report for each image.

 

Here is an example of when the report processes the error. When a user adds 1 image and renders the report the report view looks great but once they add more images and try to render the report the report view crashes.

Below is the Error and Stack Trace:

URL: /api/Reports/clients/160626-95db/instances/160630-aeac/documents/161216-3e80161216-c106/info

"message":"",
"exceptionMessage":"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index",
"exceptionType":"Telerik.Reporting.Services.Engine.DocumentRenderException",
"stackTrace":" at Telerik.Reporting.Services.Engine.Document.GetDocumentInfo()\r\n at Telerik.Reporting.Services.Engine.ReportEngine.GetDocumentInfo(String clientID, String instanceID, String documentID)\r\n at Telerik.Reporting.Services.WebApi.ReportsControllerBase.GetDocumentInfo(String clientID, String instanceID, String documentID)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(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.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()"

 

Here is the report:

namespace LT.Services.Reporting.EFV.Reports.Reports.ScannedImage
{
    partial class rptScannedImage
    {
        #region Component Designer generated code
        /// <summary>
        /// Required method for telerik Reporting designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            Telerik.Reporting.Group group1 = new Telerik.Reporting.Group();
            Telerik.Reporting.ReportParameter reportParameter1 = new Telerik.Reporting.ReportParameter();
            Telerik.Reporting.ReportParameter reportParameter2 = new Telerik.Reporting.ReportParameter();
            Telerik.Reporting.ReportParameter reportParameter3 = new Telerik.Reporting.ReportParameter();
            Telerik.Reporting.ReportParameter reportParameter4 = new Telerik.Reporting.ReportParameter();
            Telerik.Reporting.ReportParameter reportParameter5 = new Telerik.Reporting.ReportParameter();
            Telerik.Reporting.ReportParameter reportParameter6 = new Telerik.Reporting.ReportParameter();
            Telerik.Reporting.Drawing.StyleRule styleRule1 = new Telerik.Reporting.Drawing.StyleRule();
            Telerik.Reporting.Drawing.StyleRule styleRule2 = new Telerik.Reporting.Drawing.StyleRule();
            Telerik.Reporting.Drawing.StyleRule styleRule3 = new Telerik.Reporting.Drawing.StyleRule();
            Telerik.Reporting.Drawing.StyleRule styleRule4 = new Telerik.Reporting.Drawing.StyleRule();
            this.groupFooterSection = new Telerik.Reporting.GroupFooterSection();
            this.groupHeaderSection = new Telerik.Reporting.GroupHeaderSection();
            this.detail = new Telerik.Reporting.DetailSection();
            this.pictureBox1 = new Telerik.Reporting.PictureBox();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            // 
            // groupFooterSection
            // 
            this.groupFooterSection.Height = Telerik.Reporting.Drawing.Unit.Inch(0.0520833320915699D);
            this.groupFooterSection.Name = "groupFooterSection";
            this.groupFooterSection.Style.Visible = false;
            // 
            // groupHeaderSection
            // 
            this.groupHeaderSection.Height = Telerik.Reporting.Drawing.Unit.Inch(0.0520833320915699D);
            this.groupHeaderSection.Name = "groupHeaderSection";
            this.groupHeaderSection.Style.Visible = false;
            // 
            // detail
            // 
            this.detail.Height = Telerik.Reporting.Drawing.Unit.Inch(1.0000008344650269D);
            this.detail.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.pictureBox1});
            this.detail.Name = "detail";
            this.detail.PageBreak = Telerik.Reporting.PageBreak.After;
            // 
            // pictureBox1
            // 
            this.pictureBox1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(3.9418537198798731E-05D), Telerik.Reporting.Drawing.Unit.Inch(0D));
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(1.0000003576278687D), Telerik.Reporting.Drawing.Unit.Inch(1D));
            this.pictureBox1.Sizing = Telerik.Reporting.Drawing.ImageSizeMode.AutoSize;
            this.pictureBox1.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.None;
            // 
            // rptScannedImage
            // 
            group1.GroupFooter = this.groupFooterSection;
            group1.GroupHeader = this.groupHeaderSection;
            group1.Name = "group";
            this.Groups.AddRange(new Telerik.Reporting.Group[] {
            group1});
            this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
            this.groupHeaderSection,
            this.groupFooterSection,
            this.detail});
            this.Name = "rptScannedImage";
            this.PageSettings.Margins = new Telerik.Reporting.Drawing.MarginsU(Telerik.Reporting.Drawing.Unit.Inch(0D), Telerik.Reporting.Drawing.Unit.Inch(0D), Telerik.Reporting.Drawing.Unit.Inch(0D), Telerik.Reporting.Drawing.Unit.Inch(0D));
            this.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Custom;
            this.PageSettings.PaperSize = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(8.5D), Telerik.Reporting.Drawing.Unit.Inch(11D));
            reportParameter1.Name = "PageNumber";
            reportParameter1.Type = Telerik.Reporting.ReportParameterType.Integer;
            reportParameter1.Value = "1";
            reportParameter2.Name = "ImageToAdd";
            reportParameter2.Value = "D:\\KDrive\\LT001\\LT001001\\001000003.tif";
            reportParameter3.Name = "ImageExists";
            reportParameter3.Type = Telerik.Reporting.ReportParameterType.Boolean;
            reportParameter3.Value = "= True";
            reportParameter4.Name = "RegistrationNumber";
            reportParameter4.Value = "000000000";
            reportParameter5.Name = "IsEmbeddedResource";
            reportParameter5.Value = "= False";
            reportParameter6.Name = "FileResourceName";
            reportParameter6.Value = "LT.Services.Reporting.EFV.Reports.Contents.Images.eSubmission_CoverPage.jpg";
            this.ReportParameters.Add(reportParameter1);
            this.ReportParameters.Add(reportParameter2);
            this.ReportParameters.Add(reportParameter3);
            this.ReportParameters.Add(reportParameter4);
            this.ReportParameters.Add(reportParameter5);
            this.ReportParameters.Add(reportParameter6);
            this.Style.BackgroundColor = System.Drawing.Color.White;
            styleRule1.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] {
            new Telerik.Reporting.Drawing.StyleSelector("Title")});
            styleRule1.Style.Color = System.Drawing.Color.Black;
            styleRule1.Style.Font.Bold = true;
            styleRule1.Style.Font.Italic = false;
            styleRule1.Style.Font.Name = "Tahoma";
            styleRule1.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(18D);
            styleRule1.Style.Font.Strikeout = false;
            styleRule1.Style.Font.Underline = false;
            styleRule2.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] {
            new Telerik.Reporting.Drawing.StyleSelector("Caption")});
            styleRule2.Style.Color = System.Drawing.Color.Black;
            styleRule2.Style.Font.Name = "Tahoma";
            styleRule2.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(10D);
            styleRule2.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
            styleRule3.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] {
            new Telerik.Reporting.Drawing.StyleSelector("Data")});
            styleRule3.Style.Font.Name = "Tahoma";
            styleRule3.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(9D);
            styleRule3.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
            styleRule4.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] {
            new Telerik.Reporting.Drawing.StyleSelector("PageInfo")});
            styleRule4.Style.Font.Name = "Tahoma";
            styleRule4.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(8D);
            styleRule4.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
            this.StyleSheet.AddRange(new Telerik.Reporting.Drawing.StyleRule[] {
            styleRule1,
            styleRule2,
            styleRule3,
            styleRule4});
            this.Width = Telerik.Reporting.Drawing.Unit.Inch(1.0000393390655518D);
            this.ItemDataBinding += new System.EventHandler(this.rptScannedImage_ItemDataBinding);
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();

        }
        #endregion

        private Telerik.Reporting.DetailSection detail;
        private Telerik.Reporting.GroupHeaderSection groupHeaderSection;
        private Telerik.Reporting.GroupFooterSection groupFooterSection;
        private Telerik.Reporting.PictureBox pictureBox1;

    }
}

Here is the location I add the image to the report

public partial class rptScannedImage : Telerik.Reporting.Report
    {
        private static readonly CacheHelper _cacheHelper = CacheHelper.Instance;
        private Object thisLock = new Object();


        public rptScannedImage()
        {
            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
        private void rptScannedImage_ItemDataBinding(object sender, EventArgs e)
        {
            lock (thisLock)
            {
                bool imageExists = (bool)this.ReportParameters["ImageExists"].Value;
                int pageNumber = (int)this.ReportParameters["PageNumber"].Value;
                string imageFile = (string)this.ReportParameters["ImageToAdd"].Value;
                bool isEmbeddedResource = (bool)this.ReportParameters["IsEmbeddedResource"].Value;
                string fileResourceName = (string)this.ReportParameters["FileResourceName"].Value;

                if (!imageExists)
                {
                    var txtNotAvailable = new Telerik.Reporting.TextBox();
                    txtNotAvailable.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.5D), Telerik.Reporting.Drawing.Unit.Inch(2.5D));
                    txtNotAvailable.Name = "txtNotAvailable";
                    txtNotAvailable.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(7.5D), Telerik.Reporting.Drawing.Unit.Inch(5.5));
                    txtNotAvailable.Style.Font.Name = "Times New Roman";
                    txtNotAvailable.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(72D);
                    txtNotAvailable.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center;
                    txtNotAvailable.Value = "Dummy Registered Document Image for " + (string)this.ReportParameters["RegistrationNumber"].Value;
                    this.detail.Items.Add(txtNotAvailable);
                }
                else
                {
                    Image image = null;
                    // if it's not an embedded resourece 
                    if (!isEmbeddedResource)
                    {
                        // we need to clone the image for thread safety
                        image = ReportDataMethod.GetImage(imageFile);
                    }
                    else
                    {
                        image = Reporting.EFV.Reports.ReportDataMethod.GetImageFromResource(fileResourceName);
                    }

                    double width = image.Width / image.HorizontalResolution;
                    double height = image.Height / image.VerticalResolution;
                    SizeU size = new SizeU(Unit.Inch(width), Unit.Inch(height));
                    Telerik.Reporting.Processing.Report rpt = (Telerik.Reporting.Processing.Report)sender;
                    rpt.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Custom;
                    rpt.PageSettings.PaperSize = size;

                    pictureBox1.MimeType = "image/png";
                    pictureBox1.Value = image;
                }
            }
        }

 

Here is the way I append the images in the resolver

    // Add File Attachment to report
                            // Attach image files as pages
// Gets the paths
                            var pngImagePaths = ReportDataMethod.GetFilePaths(eFormID);
                            if (pngImagePaths != null)
                            {
                                var pageCountID = 1;
                                foreach (var imagePath in pngImagePaths)
                                {
                                    // Add cover page (Eventually we will add this to all E-Forms
                                    // Add scanned file
                                    // note that setting filePath or File Resource Name to null will
                                    // cause the preview to crash on reload
                                    PDFToImageParameters fileParams = new PDFToImageParameters()
                                    {
                                        FilePath = imagePath,
                                        FileResourceName = "",
                                        ImageExists = true,
                                        IsEmbeddedResource = false,
                                        PageCount = pageCountID
                                    };
                                    var fileReport = UpdateScannedImageReportWithParams(eFormID, pageCountID == 1 ? "File Attachment" : String.Empty, pageCountID++, fileParams);
                                    book.Reports.Add(fileReport);
                                }
                            }

 

Any help would be appreciated.

 

Thanks!

 

Stef
Telerik team
 answered on 15 Feb 2016
1 answer
158 views

Hi,

I'm getting error - Value cannot be null. Parameter name: instance, after I upgraded my solution to the current telerik reports verson. Can you please let me know how I can fix this issue.

Please see the attached file for more information.

 

Thanks.

 

 

Stef
Telerik team
 answered on 15 Feb 2016
1 answer
238 views
I am trying to change report definition dynamically but unable to bind datasource. Could you please help me in binding the datasource dynamically. I amusing LinqtoSQL as datasource.

 

  1. On click of a button, I am calling the constructor of my report and getting the report document and setting it to InstantReportSource's report document.
  2. I am serializing the report document to XML file and making modifying the report definition.
  3. After deserializing, how to bind the datasource before inputting the report to report viewer.

Thanks

 
 
private void button6_Click(object sender, RoutedEventArgs e)
        {
            try
            {
 
                ReportViewerWindow rvw = new ReportViewerWindow();
                Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
                instanceReportSource.Parameters.Add("ParamDivisionId", null);
                instanceReportSource.Parameters.Add("ParamStartDate", new DateTime(2014, 1, 1));
                instanceReportSource.Parameters.Add("ParamEndDate", new DateTime(2014, 2, 1).AddMinutes(-1));
                instanceReportSource.ReportDocument = new DispatchAnywhere3.Reports.Report1(_user, _repository, _adminRepo);
 
                using (System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create("C:/Temp/XML/ReportInside.xml"))
                {
                    Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
                        new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
 
                    xmlSerializer.Serialize(xmlWriter, instanceReportSource.ReportDocument);
                }
 
 
                using (System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create("C:/Temp/XML/ReportInsideSecond.xml"))
                {
                    XmlDocument document = new XmlDocument();
                    document.Load("C:/Temp/XML/ReportInside.xml");
 
                    XmlNodeList nodes = document.ChildNodes;
                    foreach (XmlNode node in nodes)
                    {
                        if (node.Name == "Report")
                        {
                            XmlNodeList nodes1 = node.ChildNodes;
 
                            foreach(XmlNode node2 in nodes1)
                            {
                                if (node2.Name == "Style")
                                {
                               node2.Attributes["BackgroundColor"].Value = "Red";
                                }
                            }
                        }
                    }
 
                    document.Save(xmlWriter);
 
                }
 
                Telerik.Reporting.Report report = null;
 
                using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create("C:/Temp/XML/ReportInsideSecond.xml"))
                {
                    Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
                        new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
 
                     report = xmlSerializer.Deserialize(xmlReader) as Telerik.Reporting.Report ;
 
                     
                     
                    
                }
          
 
                rvw.ReportViewer1.ReportSource = new InstanceReportSource { ReportDocument = report };
 
                rvw.ReportViewer1.RefreshReport();
                rvw.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
 
        }
Stef
Telerik team
 answered on 12 Feb 2016
2 answers
209 views

Hello,

I am evaluating a trial version of the Standalone Report Designer and have two reports I want to link via Drillthrough.

I believe I have followed the correct procedures to select the "interactive" field and set up the corresponding next steps:

Edit Action > Navigate To Report > Select Report Source > URL or File

Both of my reports are published to our telerik server in the same folder / category. However, when I key the URL in the source box, add proper parameters, and preview, I am receiving the following message:

 

"Unable to get report parameters.
An error has occurred.
'https://telerik.justfab.net/Report/View/LMS_DEV/Department_Overview_Report' report cannot be found."

 

This is a valid URL for the report I am trying to link to, but assuming from the error message there must be some other way to reference the URL for an existing report that already resides on our server. I tried adding .trdx extension with no success.

Please let me know the proper URL format to use when setting up simple Drillthrough connection between two reports residing on the same server.

 

Thank you!

Stef
Telerik team
 answered on 12 Feb 2016
2 answers
98 views

I'm working on a calendar report that uses a daily sub-report for each day of the month.

The issue I'm running into is that with auto-scaling, each day scales differently based on the data for that day, meaning that the sub-reports are all displayed using different scales, and so don't lend themselves to side-by-side comparison.

It's impossible to know before run-time what the maximum scale for the entire month will be, so I can't hard set the axis scales either. Is there a way to 'pass in' the required scale to the sub-report along with the other parameters? I tried to put a formula in the CoordinateSystem.YAxis.Scale.Maximum property, but it seems to only accept a hard value and not a formula.

Peadar
Top achievements
Rank 1
 answered on 12 Feb 2016
1 answer
223 views
I am using the HTML 5 report viewer and currently when the user double clicks on the page, it toggles between Zoom In, Zoom Out, and Toggle FullPage Mode.  Users want to double click to select data on the report and the zoom behavior is counter intuitive to their expected behavior.  Is it possible to disable this toggle mode?
Stef
Telerik team
 answered on 11 Feb 2016
5 answers
140 views
Hi,
  I am new to telerik reporting. I have gone through some of your videos and tutorials. I have some questions regarding what is the best way to use Telerik reporting for my purposes. Hope i get the answers here;

1. I have a requirement where at the end of each day i need to email invoices to different people(dynamic list) whose email ids should be picked from a table in the database. I understand that we can create invoicing reports in telerik. But i would like to email this report in pdf format to a list of people (and the list of email ids is fetched from the database). Can this be done? if yes, then how. Can you point me in the right direction.

based on what i have read, I think i should do the following:
1. Create a report in telerik reporting as a class library
2. Then create a c# console application which should render the above report into a pdf format and then email to people

Is this the right way to do it. Is there any other better way where we can automatically achieve this without writing any c# application.

please an any body help me on this.


Thanks
Stef
Telerik team
 answered on 11 Feb 2016
1 answer
457 views

Hi,

 In my WPF app, I have a report designed by default for A4 paper and I want to fit it to print on an A5 printer.

I have read threads on this forum about the ViewerPrintScaling (especially this one http://www.telerik.com/forums/dynamic-report-column-size#R757mvc1xkKirZXyJj7MBw) and I tried to used this option.

Here are the results :

- works fine when I generate a pdf file on disk using the ReportProcessor.RenderReport function, then print-it with right-click 

- does not work in ReportWiewer (always printed in A4)

- does not work when directly printing using the ReportProcessor.PrintReport function (always printed in A4)

Am I missing something ? When I read the comment of Stef from Telerik Team, I understand that this option is always taken in account, either when rendering or when directly printing...

 Thanks by advance for your help,

Aurélien

Hinata
Top achievements
Rank 1
 answered on 11 Feb 2016
1 answer
210 views
hello,
is it possible to overlap one element that is placed in the footer section over the detail section?
see attchments
thanks
viktor
Katia
Telerik team
 answered on 10 Feb 2016
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?