Telerik Forums
Reporting Forum
1 answer
175 views
Hi there -

I am thoroughly frustrated with the reporting tool.  I have been working on a voucher statement project for some time and experiencing that the reporting tools do not simple things you would think it would do.  I have made design changes to reports to work around printing issues, however I find myself having other issues.  Therefore, I am currently experiencing several issues and I will try to explain them as best I can.

To describe what the project entails, this is a simple reporting solution for printing credit vouchers.
I get a list of payment numbers to read and process a statement page, and credit voucher for each payment.

I am using a report book to add the reports as they are processed, so I can print them as a whole.
The sequencing of the entire report book should be as follows:

1 -  Header Report (Displays general text)

2 -  Credit Voucher Statement (A list of details that make up the voucher)
3 -  Actual Credit Voucher (Single Page coupon)

NOTE: If there are multiple payment numbers, I print reports 2 and 3 in a loop, adding them to the report book as they are processed.

4 - Summary report (Shows all the credit vouchers that were printed and other summary information)

The reports print on a duplex printer, although I try to modify that setting depending on which report is printing. 
Each report should start on a fresh sheet of paper (Which it does not currently do well.)

In the code (below), I loop through the payment numbers and pass the correct parameters to the reports.
However, when adding reports 2 and 3 to the report book, the first payment number gets repeated for the total number of payments listed.
When the summary report is printed, it too only prints the summary for the first record. 

Even when I view the data and parameters being passed to the report, they are all correct.
I'm at my wits end with this project / product and looking for solutions immediately.  There are other issues I have with the product that may come up through this dialog that may need to be worked out.

Below is the code that generates the reports and report book.  Please help provide me a solution to printing these reports.

Regards,
Bob

' Generate the reports
Me.Cursor = Cursors.WaitCursor
 
' Initialize print settings
Dim printerSettings As New System.Drawing.Printing.PrinterSettings
Dim printerController As New System.Drawing.Printing.StandardPrintController
Dim reportSource As New InstanceReportSource
 
Dim reportProcessor As New ReportProcessor
reportProcessor.PrintController = printerController
 
' Create the report book to add reports
Dim reportBook As New ReportBook
reportBook.DocumentName = "Credit Vouchers"
 
' Print the report header
printerSettings.Duplex = Printing.Duplex.Simplex
 
Dim rptHeader As New CreditVoucherReportLibrary.ReportTitle
reportBook.Reports.Add(rptHeader)
 
Dim c As Integer = 0
Dim firstCV As String = ""
Dim lastCV As String = ""
 
Dim cn As New SqlConnection(My.Settings.OMSConnectionString)
Using cn
    cn.Open()
 
    ' Get the list of voucher numbers to print
    Dim cmd As SqlCommand = New SqlCommand("Accounts_Payable.get_Credit_Vouchers_Lot_list", cn)
    cmd.CommandType = CommandType.StoredProcedure
 
    IIf(CreditVoucherTextBox.Text = "", Nothing, CreditVoucherTextBox.Text)
 
    cmd.Parameters.AddWithValue("@Year", YearComboBox.SelectedItem)
    cmd.Parameters.AddWithValue("@Month", PeriodComboBox.SelectedItem)
    cmd.Parameters.AddWithValue("@Payment_Number_Code", IIf(CreditVoucherTextBox.Text = "", Nothing, CreditVoucherTextBox.Text))
 
    Try
        Dim r As SqlDataReader = cmd.ExecuteReader
        If r.HasRows Then
 
            While r.Read
 
                Dim rptVoucherStatement As New CreditVoucherReportLibrary.CV_Statement
                Dim rptVoucher As New CreditVoucherReportLibrary.CreditVoucher
 
                ' Print Credit Voucher Statement
                rptVoucherStatement.ReportParameters("YearPeriod").Value = YearComboBox.SelectedItem
                rptVoucherStatement.ReportParameters("MonthPeriod").Value = PeriodComboBox.SelectedItem
                rptVoucherStatement.ReportParameters("PaymentNumber").Value = Trim(r(0))
 
                printerSettings.Duplex = Printing.Duplex.Horizontal
 
                ' Add the voucher statement to the report book
                Try
                    reportBook.Reports.Add(rptVoucherStatement)
                Catch ex As Exception
 
                End Try
 
                ' Print Credit Voucher
                c += 1
 
                rptVoucher.ReportParameters("YearPeriod").Value = YearComboBox.SelectedItem
                rptVoucher.ReportParameters("MonthPeriod").Value = PeriodComboBox.SelectedItem
                rptVoucher.ReportParameters("PaymentNumber").Value = Trim(r(0))
                rptVoucher.ReportParameters("LastUpdatedBy").Value = "System"
                rptVoucher.ReportParameters("IsReprint").Value = False
 
                If c = 1 Then
                    firstCV = Trim(r(0))
                Else
                    lastCV = Trim(r(0))
                End If
 
                printerSettings.Duplex = Printing.Duplex.Simplex
 
                ' Add the voucher to the report book
                Try
                    reportBook.Reports.Add(rptVoucher)
                Catch ex As Exception
 
                End Try
            End While
        End If
    Catch ex As Exception
 
    End Try
End Using
 
' Print the summary page
Dim rptSummary As New CreditVoucherReportLibrary.CV_Summary_Report
 
Try
    Dim range As String = ""
    If c = 1 Then
        range = firstCV
    Else
        range = firstCV & " - " & lastCV
    End If
 
    rptSummary.ReportParameters("YearPeriod").Value = YearComboBox.SelectedItem
    rptSummary.ReportParameters("MonthPeriod").Value = PeriodComboBox.SelectedItem
    rptSummary.ReportParameters("PaymentNumber").Value = IIf(CreditVoucherTextBox.Text = "", Nothing, CreditVoucherTextBox.Text)
 
    rptSummary.ReportParameters("RangeOfVouchers").Value = range
    rptSummary.ReportParameters("NumberOfVouchers").Value = c
 
    printerSettings.Duplex = Printing.Duplex.Horizontal
 
    ' Add the summary to the report book
    reportBook.Reports.Add(rptSummary)
Catch ex As Exception
 
End Try
 
' Print the report book
If PrintPreviewCheckBox.Checked Then
    Dim dlg As New CreditVoucherPrintPreviewForm
 
    dlg.reportBook = reportBook
 
    dlg.ShowDialog()
Else
    reportSource.ReportDocument = reportBook
    reportProcessor.PrintReport(reportSource, printerSettings)
End If

Nasko
Telerik team
 answered on 16 Apr 2014
6 answers
290 views
Hi

We are SilverLight ReportViewer and displaying pie charts in the reports. The pie chart is not being displayed sometimes when seen in the reportviewer but when saved to pdf we are able to see all the pie charts in the reports. Please find the attached screenshots for furthur reference and let us know if anything has to be done from our end.

And the behaviour is inconsistent in reportviewer, so its not reproducible always.

Thanks in advance
Ravindra 
Nasko
Telerik team
 answered on 16 Apr 2014
7 answers
398 views
I have a EF 6 datasource configured and working but I'm finding it very limited.  There seems to be no way to query the datasource using Linq from the designer.  I was expecting it to work like the SQL datasource where a query can be specified and then embedded in the report.
Nasko
Telerik team
 answered on 16 Apr 2014
2 answers
111 views
Hello, 

I'm working on an applicationt that is using wcf services to access a remote database, and csv stored to the isolated storage for managing offline mode. 
The need I have it's to give users the possiblity to continue generating reports using local data. Is it possible to do it using Telerik SL components? 

Thanks a lot for your help. 
Regards
Stef
Telerik team
 answered on 16 Apr 2014
5 answers
311 views
Hi,

I have created a C# windows forms application to export reports programatically. Reports are created using standalone report designer and added in a folder within the application. Reports have a multivalue parameter site whose value is set to AllValues(Fields.Id). AllValues function by default selects all site values. While running the application, report is exported programmatically. But, when I check the report that is created, it has the following message
An error has occurred while processing Report 'GameMetric':
The expression contains undefined function call AllValues().
Following is the piece of code which exports report programmatically.
try
                    {
                        Telerik.Reporting.UriReportSource URI = new Telerik.Reporting.UriReportSource();
                        string reportKey = dt.Rows[i]["report_key"].ToString();
                        string reportName = dt.Rows[i]["report_name"].ToString();
                        appendMessage("Run Report: " + reportName, ref message);

                        if (dt.Rows[i]["CustomFlag"].ToString() != "Y")
                            URI.Uri = Directory.GetCurrentDirectory() + "\\Reports\\" + reportKey + ".trdx";
                        else
                            URI.Uri = Directory.GetCurrentDirectory() + "\\Reports\\" + "Dynamic Report.trdx";

                        XmlReaderSettings settings = new XmlReaderSettings();
                        settings.IgnoreWhitespace = true;
                        using (XmlReader xmlReader = XmlReader.Create(URI.Uri, settings))
                        {
                            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
                            ReportViewer reportViewer = new ReportViewer();
                            Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
                                                  new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();

                            Telerik.Reporting.Report report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
                            string newConn = Common.changeConnectionString(Properties.Settings.Default.ParafaitConnectionString, "ParafaitMultisite");
                            System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
                            //SetConnectionString(newConn, report);
                            reportViewer.Report = report;
                            reportViewer.ReportSource.Parameters.Add("fromdate", fromDate.ToString());
                            reportViewer.ReportSource.Parameters.Add("todate", toDate.ToString());
                            //reportViewer.ReportSource.Parameters.Add("offSet", Convert.ToString(ParafaitTimezone.FinalOffset()));
                            reportViewer.ReportSource.Parameters.Add("user", "Parafait Scheduler");
                            reportViewer.ReportSource.Parameters.Add("loggedInUserName", "Parafait Scheduler");
                            reportViewer.ReportSource.Parameters.Add("role", " ");
                            reportViewer.ReportSource.Parameters.Add("loggedInUserId", Common.getLoggedinUser());
                            string reportID = dt.Rows[i]["report_id"].ToString();
                            reportViewer.ReportSource.Parameters.Add("reportID", reportID);
                            reportViewer.ReportSource.Parameters.Add("isCorporate", "Y");
                            //reportViewer.RefreshReport();
                            string fileName = "D:\\Parafait Home\\Reports\\" + reportName + TimeStamp + ".pdf";
                            try
                            {
                                Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", reportViewer.ReportSource, deviceInfo);
                                using (FileStream fs = new FileStream(fileName, FileMode.Create))
                                {
                                    fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
                                }
                            }
                            catch (Exception ex)
                            {
                                appendMessage(ex.Message, ref message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        appendMessage(ex.Message, ref message);
                    }
                }
                
                appendMessage("Done creating reports", ref message);

I have added the assembly reference in report designer config file.

When I run the same set of reports in a web form it seems to be working without any issues.
What wrong could I have done?
Hinata
Top achievements
Rank 1
 answered on 16 Apr 2014
5 answers
158 views
Guys,
This is a breaking change and I haven't yet figured out why it is happening to my project when I am upgrading to Q1 2014.
The xaml code is -
             xmlns:tr="http://schemas.telerik.com/wpf"

        <tr:ReportViewer x:Name="reportViewer" HorizontalAlignment="Stretch" Margin="10"
                         ReportSource="{Binding ReportSource}">
            <telerikControls:StyleManager.Theme>
                <telerikControls:Windows7Theme />
            </telerikControls:StyleManager.Theme>
        </tr:ReportViewer>

Application breaks in execution with message -
'The invocation of the constructor on type 'Telerik.ReportViewer.Wpf.ReportViewer' that matches the specified binding constraints threw an exception.' Line number '34' and line position '10'

I am referencing to following dlls in the project :
1. Telerik.reporting - v4.0.30319
2. Telerik.ReportViewer.Wpf - v4.0.30319
3. Telerik.Windows.Controls - v4.0.30319
Stef
Telerik team
 answered on 16 Apr 2014
5 answers
1.3K+ views
Hi All,

I have report with a picturebox:

Size = 2in, 0.76in
Anchor = Right, Top
Sizing = ScaleProportional

I would like to have the content of the picture box aligned to the right side. Is there any way how to do that? 

In more detail:
The value of the image is set in the code based on the current customer logo. Each customer has different proportion of their logos. The size of the PictureBox is the maximum size the logo could occupy on the report. I want to have the logo as big as possible (but not more then the maximum size) and be aligned to the right side of the report.

Thank you!

Pavel
Joel
Top achievements
Rank 2
 answered on 16 Apr 2014
12 answers
371 views
Should i be able to use multipe subreports in a report ?

i have a reports on a DataSet created from an XML file. The main report is on table A. The first subreport is on table B. I created a second subreport and set its datasource to table C but it always shows the data from table B

i am using the NeedDataSource event in the main report to load the xml file and set the datasource of the main report to its table

i am also using the NeedDataSource event for each subreport to set their datasources.

no matter what i do the second subreport always shows the same data as the first subreport

is it not possible to have multiple subreports ?

thanks

Mike


PAGCA
Top achievements
Rank 1
 answered on 15 Apr 2014
3 answers
313 views
Hi,

I have a simple case scenario where I programatically export my report to various file format then email our report to our customer.
Now it happens that those reports contains no data and in this case we want to send a proper email informing them that their report contains no data (which is good usually because we send alerts report :) )

anyway, it sounds like a simple enough scenario though I couldn't yet place my hand onto it ...

code looks like this:
RenderingResult result = reportProcessor.RenderReport(exportFormat, telerikReport, null);
 if (result.HasErrors)
wish I could say if error == "No data" then ...else ...

any help / suggestion?
Regards
Jim
PS: version used Q1 2011 SP1 (5.0.11.510)...I know time to upgrade right ;)
Peter
Telerik team
 answered on 15 Apr 2014
5 answers
540 views
Using Reporting Q1 2013. I have a HTMLTextbox inside a data bound table column. When report runs, the HTML content shows up fine but text appears to be trimmed because it's not automatically wrapping. See the attached screen shot.

HTMLTextbox has 'CanGrow = True' and 'CanShrink = False'.

Appreciate your help.
Stef
Telerik team
 answered on 15 Apr 2014
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?