Report Parameters In Reporting Services

Nov 21, 2004

Hi guys & gals

I'm just setting up Reporting Services for our company and it's a great product, no doubt about it. However, I've come across a problem I can't solve and I wonder if any of you can help.

I've produced a sales report and I want my users to be able to enter a list of sales periods to include on the report. For example, the user might want to view the report for periods 10,11,13,14 and 17 and exclude periods 12,15 and 16. Obviously, the underlying query will probably involve an IN() clause but I'm struggling to think of a way that the user might be able to enter these parameters.

The most obvious way might be by typing in a comma separated string, but I don't know how to then put those values into the query.

Anyone got any ideas?

View 1 Replies


ADVERTISEMENT

Reporting Services :: Passing Cascaded Parameters From Main Report To Drill Through Report In SSRS?

Sep 16, 2015

I am trying to develop a report from cube,and it has one drill through report.when i click on sales amount field on main report,then it open the drill through report with details.Here i passed the **(category,subcat,product)parameters(Cascaded)** to drill through report in action part of main report.In my main report i have two columns .

columns are **Level**  and              **Salesamount**.  

Values are like  

**[-]category**              **100**
    **[-]subcat**             **50**
         **product**          **30**

when i click on 100, parameters are passed & it open the detail report correctly, but when i click on 50,the values for subcat parameter is not getting values in detail report and same as the product also.

Here i used the expressions in parameter values

**pCategory**----iif(inscope(category),!fields.category.value,split(join(Parameters!category.value,","),","))

**psubcat**----iif(inscope(subcat),!fields.subcat.value,split(join(Parameters!subcat.value,","),","))

**pproduct**----iif(inscope(product),!fields.product.value,split(join(Parameters!product.value,","),","))

View 3 Replies View Related

Reporting Services :: Way To Subscribe SSRS Report Using Dynamic Parameters For Email And Trigger Report

Feb 8, 2015

Is there a way to subscribe SSRS report using dynamic parameters for email and trigger the report from autosys job so that report should generate the exact time the job is triggered.Let me describe, my SSRS report should be triggered on success of one autosys job. i need to send email parameter and time of report schedule from this autosys job.

View 3 Replies View Related

Its Not Report Parameters (ITS REPORTING SERVICES I THINK)

Jan 5, 2007

i am trying to generate a report based on 3 parameters
age, location, ethnciity

every thing works fine in data and layout tab,
when i run the preview tab, it give me the option to input paramaters and then when i hit veiw report, it shows processing report.... (indefinite) time.

i tried executing the query in data tab, it takes less than a sec.

any ideas??

am i doing somethign wrong in parameters??

View 7 Replies View Related

Reporting Services :: Same Report Different Parameters

Sep 8, 2015

1 report but different departments run this report with different parameters. Atm I have copied this report for the 4 departments and adjusted the default parameters accordingly (highly inefficient). Isn't there a way to just have one report and that I can adjust the default parameters in code based on user or group ?

View 6 Replies View Related

Reporting Services :: Using Parameters To Filter A Report?

Jul 7, 2015

I have a report I'm working on that provides a census of members. These members have certain properties;

Load date,Report Type,Clinic,Care Manager,PCP Name.

The census is from an outside group and what I do is massage it for our internal databases and reports to our care managers.

The report starts out by returning only those entries that were received in the last report from the outside vendor and I filter each of the parameters by using a WITH statement and an INNER JOIN, as follows;

WITH Date_of_Most_Recent_Census AS
(
SELECT
MAX(Load_Date) AS [CurDate]
FROM
Census_Rpt_Final
)

[Code] ...

The default is for all parameters to start out with all possible values for the current load date. But, I need to be able to filter the available - and default  - values for each parameter based upon the selection of the other parameters.

So, the Load Date is built in by use of the CTE that is a part of all the parameters. But, I need the report to allow the end user to select from each of the others, but limiting what is avaliable for selection based upon the settings of the other parameters.

For example, the second parameter is the Report Type. It can be either "Hospital," or "SNF." But, not all Clinics, Care Managers or PCPs may have an entry in both types. So, if the user selects, say, "Hospital," all the parameters would alter their available and default values such that they only include options where the census shows they are a "Hospital" entry.But, not all Clinics in the most recent census may have both report types. So, if the end user selects a particular clinic, it would also recalculate the available and default values for Report Type, as well as those beneath it on the list. And, likewise for the remainder of the parameters.

My initial thought was to add WHERE statements to the datasets controlling each parameter, but SSRS keeps asking me to define the parameters when I click out of the dataset's properties. Now, I know that SSRS is a single pass process - and, I'll cross the bridge on adjusting parameters defined earlier in the list when I come to it - but I thought that parameters lower in the list would update, since they'd have their values defined.For instance, the Clinic parameter is after Report Type, so the code I used to set up Clinic was;

WITH Date_of_Most_Recent_Census AS
(
SELECT
MAX(Load_Date) AS [CurDate]
FROM
Census_Rpt_Final
)
SELECT DISTINCT

[code]....

But, this asks me to define @ReportType, even though it precedes Clinic on the parameter list.

View 2 Replies View Related

Reporting Services :: Scheduling MS Report With Date Parameters

Jun 2, 2015

I need to schedule a report with date ranges which change from month to month.  Is there a scheduler date function I can place in the parameter field(s) for that report?

View 4 Replies View Related

Reporting Services :: Running Report Initially Before Parameters

Jul 20, 2015

On my report, I have two parameters that are used to filter my report. I would like for the report to initially run without filters and without having the user required to input parameters. I know that this can be accomplished by using the multi value parameter and having it "Select All" by default, but for my parameters, I would like for each parameter to only allow the user to select one value. Is it possible to have this requirement without having to enable select multi values?

View 2 Replies View Related

Reporting Services :: Placement Of Parameters In Report Header

Jul 2, 2015

I've got a feeling that the answer is, "can't be done," but I'll go ahead and ask the august members of this forum, anyway. Is it possible to alter the placement of the Parameter fields when previewing a report?

At the moment, it seems that they form in a column of twos, reading from left to right. I see how the ORDER is affected, by changing the order of the parameters in the Report Data window, but can I change the number of columns?

View 2 Replies View Related

Reporting Services :: Report Not Running After Adding Cascading Parameters

Sep 2, 2015

After adding cascading parameters my report which was running earlier is failing. I'm using Report builder 3.0, windows 2008r2, am running the report from the server

Error message "An error has occurred during report processing.(rsProcessingAborted)

Query execution failed for dataset 'LastName' (rsErrorExecutinGcOMMAND)
Incorrect Syntax near ','."

Is there a way where i can look up the code in xml using report builder or some other way so that i can delete the extra '','.

View 6 Replies View Related

Reporting Services :: Report Parameters PTimeframe (Day - Week - Month)

Aug 6, 2015

I'm using Server 2012 R 2 with SQL Server 2012 Reporting Configuration Manager 11.0.5343.0 . The default time values (pTimeframe) for generating the report of my DPM Summary are the default values Day - Week - Month.

How can I define the value "Last 24 hours" for example?! Because the DPM Server does it backups the whole night starting at 08:00pm the day before and the result of the finished Backups of yesterday won't be shown when I use the defaut value "Day".

I want to send a subscription every morning for the backups only of the night before (not the whole week).

View 2 Replies View Related

Reporting Services Data Extension - Passing Report Parameters

Jul 24, 2007

I have created a custom data extension.



I am using this custom data extension from BI Studio.



Que1: I want to create report parameters from BI studio and capture them in my Data Extension.



Que2: Every report parameter has so many properties, like hidden, internal, default value etc, how do capture that information in my data extension, the parameters only give me name and value.



Que3: I know I can capture command Text. So My command can be Select * From tablename where fieldname= @myFieldname. Once I get this commandText in my data extension, How do extract parameters of the command?



Que4: If I have any custom attributes in my RDL file, Can I capture them in my Data Extension ?



Any help is appreciated...













View 1 Replies View Related

Reporting Services :: Parameters Drop Down Selection Not Showing In The Report?

Aug 31, 2015

I created a re port using the Report builder. The report runs fine. I want to create a parameter on the report. I created a new dataset with the query "select distinct dept from table" . Then i created a new parameter to get the values from the second dataset. After running the reports when i selected 2 departemnts, its still showing all the records.

View 3 Replies View Related

Reporting Services :: Send A Report To Various Email ID Based On Parameters?

Jun 9, 2015

I need to send a report to various email id based on parameters.

I have a report which has a dropdown which shows the list of parameters. I need to send report to 3 different email ids with different parameters. How to do that?

View 6 Replies View Related

Reporting Services :: Parameters Needed For Connection And Again At Report Run-time

May 5, 2015

In VS2008 SSRS, when creating a dataset, only the name of the stored procedure was required.  When populating the dataset, VS prompted for the parameters, whether or not there were any.  In VS2010, the name of the stored procedure is not enough if there are parameters.When creating a dataset in Visual Studio 2010 for databases and stored procedures in SQL 2012, I must provide (what should be) run-time parameters to obtain a field list and then to preview the report. 

So the embedded dataset looks like this (wherein the only parameter is a password): exec dbo.spu_procedure1 @PW='999'.This works well and as expected during report design and development.  But 999 must be provided at run-time by the requester, and not in the dataset definition.  If I remove the parameter in the dataset's exec string before deploying the report, the field list is cleared and the report is unusable. So I cannot overcome what seems a contradiction: necessary to obtain a field list, but "yet-to-be-provided" when the user selects the report.

By keeping @PW='999' in the dataset specification, the user cannot override the parameter and automatically has a password to view the report.  

View 3 Replies View Related

Reporting Services :: Unable To Generate Report With URL With StartDate And EndDate Parameters?

Aug 14, 2015

i have problem generating the SSRS Reports. 

i have Report URL  with 2 parameters-- @StartDate and @EndDate

when i hard coded the values and copy the URL in IE, Report gets generated

sample URL's:

[URL]

but when i use Parameters--Report is not getting generated.

[URL]

Below is the error;

Reporting Services Error

The value provided for the report parameter 'StartDate' is not valid for its type. (rsReportParameterTypeMismatch)

SQL Server Reporting Services

View 2 Replies View Related

Reporting Services :: Defining Oracle Query Parameters - Report Designer

Sep 16, 2011

I am a beginner with Report Designer (and with Reporting Services).  Following the tutorials 'Adding parameters to filter Reports ...' I tried using the @symbol to add a parameter to my query: where code = @code_value...I get the error: ORA -000936 missing expression (msorlib) Is there another syntax that I should use to define a parameter/variable in query for my oracle dataset?

View 4 Replies View Related

Calling A Code Block Using Parameters In A Report Of Sql Server Reporting Services

Dec 18, 2007


Hi

This is the code which I have written in code window.

Public Shared Function CalcLocalFactor(ByVal CalcLifeCode As Integer, ByVal CalcFiscalAge As Integer, ByVal CalcLifeYearsUsed As Double, ByVal CalcLocConvention As String, ByVal CalcSRate As Integer) As Double
Dim locCalcFiscalAge As Integer = 0
Dim locFactor As Double= 1.0
Dim locFactor1 As Double = 1.0
Dim REM1 As Integer = 1
Dim DEP As Double = 0
Dim YR As Integer
Dim HALF_YEAR As Double
Dim LINEAR As Double
Dim MACR As Double
If CalcFiscalAge > CalcLifeCode + 1 Then
locCalcFiscalAge = 0
locFactor = 1.0
End If
If (CalcLocConvention <> "HALF-YEAR" And CalcLifeYearsUsed < CalcLifeCode) Then
locFactor = Math.Round((CalcLifeYearsUsed / CalcLifeCode), 4)
End If
If (CalcLocConvention = "HALF-YEAR") Then
for YR = 1 to CalcFiscalAge step 1
If YR = CalcLifeCode + 1 Then
locFactor1 = 1
Exit For
End If
If (YR = 1 Or YR = CalcFiscalAge) Then
HALF_YEAR = 2
Else
HALF_YEAR = 1
End If
LINEAR = Math.Round(REM1 / (CalcLifeCode - YR + 1.5) / HALF_YEAR, 4)
MACR = Math.Round(REM1 / CalcLifeCode * CalcSRate / HALF_YEAR, 4)
If MACR >= LINEAR Then
DEP = MACR
Else
DEP = LINEAR
End If
locFactor1 = locFactor1 + DEP
REM1 = 1 - locFactor1
locFactor = locFactor1
Next
End If
Return locFactor
End Function

I'm calling this code in a Report Parameter like below:

=Code.CalcLocalFactor(Parameters!CalcLifeCode.Value,Parameters!CalcFiscalAge.Value,Parameters!CalcLifeYearsUsed.Value,Parameters!CalcLifeYearsUsed.Value, Parameters!CalcSRate.Value )

It is working fine for the first record where as for other records, the value is not getting changed. i.e. the first records value is coming repeatedly for all other records also.

How can I dynamically change the parameter values of the function?

Parameter is not accepting directly the field names, hence I used other parameter to initialize the field and used that parameter for this.

Ex. Parameter Name ; FieldPurchDate (internal) FieldName : PURCHDATE
Other parameter: FieldInDate (internal) FieldName : InDate

While initializing the new parameter CalcPurchDate,, I used an expression for this: Parameters!CalcFiscalAge.Value

=iif(Parameters!FieldPurchDate.Value is nothing, Parameters!FieldInDate.Value,Parameters!FieldPurchDate.Value)

and using this CalcPurchDate for processing of the parameter:

These are some of the things , I am doing ....

Please let me know how to fix this issue...

Thanks in advance

Regards,

Radhika

View 3 Replies View Related

Reporting Services :: Strip Unwanted Characters From Parameters For SSRS Report

May 22, 2015

I have a third party app that passes parameters (main dataset query) from the app to SSRS.  Unfortunately, when the parameters are passed from the app they will contain equal signs ("=") in front of each parameter.  For example, the parameters that may be passed to the main dataset query should be:

"HYDRO, OKO, ONEPL, TECHNI"

However, the parameters that are passed from the app, get to SSRS as:

"=HYDRO, =OKO, =ONEPL, =TECHNI"

Again, this is for the main dataset query and there may be one parameter or there may be any number of them.

Basically, I need to strip the "=" signs from the parameters. whether there is one parameter or ten.

I believe that I will need a custom function to strip the equal signs?

View 5 Replies View Related

Reporting Services :: Can The Report Parameters Be Passed To Query Of Referenced Dataset

Sep 29, 2015

So I have a report that uses an MDX query to fetch the main data for the tablix.  Then I have a custom row added which pulls data in via a Lookup function and references a different dataset.  The report has 3 parameters.  Each dataset uses those 3 parameters in its underlying query.  However, the dataset referenced in the lookup function doesnt seem to be updating when change the parameters and re-run the report.

View 2 Replies View Related

Reporting Services :: Passing Report Parameters To A Query Using WCF Data Source?

Nov 29, 2010

I am attempting to pass report parameters to my query. My report's data source is a WCF web service. I can run normal queries fine, but I have found that without the know-how to pass parameters to my query I am limited with my capabilities.

Assume a string parameter named "Name" with a specified default value of "Jmachol90", how would I pass that into the following query at the designated place:
  
<Query>
          <Method Namespace="http://schemas.microsoft.com/sqlserver/masterdataservices/2009/09" Name="SecurityPrincipalsGetRequest">
          <Parameters>
          <Parameter Name="Criteria" Type="XML">
<DefaultValue>

[code]....

View 17 Replies View Related

Reporting Services :: Adding Drill Through Parameters Increasing Rendering Time On Report Server

Nov 2, 2015

I have a report which takes around 5 seconds when run in BIDS but takes around 20 seconds when deployed on report server.Execution log says TimeDataRetrieval is around 3-4 seconds and  rendering time is around 15-17 secs.From this report I am passing 8 parameters to a  drill through report and there are 36 text boxes where I have defined these parameters for drill through action.All these parameters are populated in main dataset.When I deployed the same report without any drill through action and parameter, it takes 5 seconds.So I am suspecting that because of drill through parameters report is taking more rendering time on server.I am using 2008R2 and IE11.

Is it expected behavior that due to so many parameters for drill through action, report will take more rendering time?If yes, then why is it not taking same time in BIDS?

View 5 Replies View Related

Reporting Services :: Include Special Characters In Passing Parameters In JavaScript In Drill Through Report

Sep 6, 2015

I am passing a field value from main report to a parameter in a drill through sub report. But some field values contain 'special characters'. Those field values that contain special characters are not working for drill through. Javascript code to include special characters to pass to sub report parameter?

View 3 Replies View Related

Reporting Services :: Start And End Date Parameters Report In SSRS 2008 Is Not Running On Runtime?

Aug 27, 2015

I made one report in SSRS 2008 in which getting data from one SharePoint List.

three parameters in report :

Country
StartDate
EndDate

I am using query which I created with CAML.

query is running well and data is coming correctly if I run this on Query designer.and date format must be YYYY-MM-DD.but when I try to run through on run time then the date control is showing format dd/mm/yyyy.

I change the regional settings of windows and SharePoint site to English(United States). and when I select date control it is also putting date in format like "YYYY-MM-DD'. and in that format report is working well in Query designer view.But on run time still it is not working.

View 3 Replies View Related

Reporting Services :: Adding Values To Parameters In Dropdown Prompts In Reports In BIDS Or Report Builder

Nov 20, 2015

I run these stored procedure to build the report and I am able successfully to build the report but I need some prompts to in the report to get the specific data .

ALTER
PROCEDURE [dbo].[Sharepoint_Ticket_Report]
@StartDate
DATETIME,
@EndDate

[Code] ....

And for prompts how to create created_by and message_type dropdowns as shown in picture.

View 7 Replies View Related

Reporting Services :: SSRS Report Parameters Getting Reset After Hitting Apply (Sharepoint Integrated Mode)

Mar 6, 2015

We have SSRS reports (pointing to SQL 2012) containing cascading parameters that we have deployed on SharePoint 2013 and once a user makes a selection to the parent parameter, child parameters are getting refreshed based on the selection in the parent parameter and then we see this:

Once we hit Apply, the Loading image comes up and approximately10 seconds later, The whole webpage gets refreshed and the parameter selections get reset to default parameters. 

This is getting frustrating because there are about 10 parameters in the report and once a user makes selections and hit apply if the page gets reset, the user has to make all the selections again.

We are working with Microsoft support on this who suggested us to increase the timeout setting of DistributedCache service on all our SharePoint servers which did seem to work initially but I do see this issue happening occasionally.

View 4 Replies View Related

Analysis Services 2000 + Reporting Services 2005 + Parameters

Sep 16, 2007



Hi All,

I'm trying to create reports in RS2005 using AS2000 as my data source. I understand that if I use RS2005 on AS2000, I wont be able to enjoy the OLAP based parameters as in using AS2005. Does anyone know an easy way to easily use Parameters in RS2005 while still using AS2000?

Regards,
Joseph

View 1 Replies View Related

Parameters In Reporting Services And Data Source Is Analytical Services

Dec 10, 2007



My requirement for the parameter is multivalue parameter with a text box. for example when user enters aa15 it need to include product aa15. when the user enters aa15, aa16, zz15 than it needs to include all the three products. the last case is when the user enters AA** than i need to inclued all the products start with AA. when i use default multivalue parameter with data source analytical services than i am getting a drop down box. I dont want that. I need a text box where user can enter the value.
1. In sql we have a like key word to query . for example select * from product where product like "AA%".
what is equavalent mdx query to get such results ?
2.How to impliment the multivalue parameters without using dropdown box?

View 1 Replies View Related

About Reporting Services Parameters On 2nd

Mar 2, 2008



Any body plese tell me How to set the Parameters at the time or report design and how to use that parameter to call report from web application.Suppose i want to display report depend on Prodid(field in table).
And Suppose i want to display report between dates.

Regards.

View 5 Replies View Related

About Parameters In Reporting Services

Mar 4, 2008

I have ony query in my dataset at design time with parameters.
I am getting the correct data when i pass parameters.
Supose,i dont pass any parameters,I need Total data.
Now how can i write other query in my Data set.
Regards

View 4 Replies View Related

SQL Reporting Services Parameters

Dec 13, 2007

Hi Friends,

We are implementing one SQL Server 2005 Reporting services for my client. I want to know, is there any possibilty to keep track the parameters at SQL Reporting sever side, which i am sending it from my UI.

Please help me in this regard.

Thanks,
Rao.

View 3 Replies View Related

Reporting Services :: Add Sub-report To Main Report Using Report Builder?

Sep 9, 2015

I just created a report builder. I have a main report and i wanted to create a sub report. why i cant or i cant view the path or the folder of my  .rdl file to be use as my sub report.

View 5 Replies View Related

SQL 2000 Reporting Services - Parameters

Mar 23, 2004

I am trying to figure how to programmatically pass parameters to the report in SQL Reporting Services using web service API and then send this report to the printer. I found code in C# on how to print and it does work very well. I am hoping to add report parameters to this module. Any ideas, samples or help would really be appreciated.


here is the code for printing

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.IO;
using System.Web.Services.Protocols;
using PrintReport.reportserver;
using System.Runtime.InteropServices; // For Marshal.Copy

namespace PrintReport
{
/// <summary>
/// A simple console application that demonstrates one way to
/// print Reporting Services reports to a printer.
/// </summary>
class app
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
PrintExample pe = new PrintExample();
// The name of the printer should be added here;
// this could be a local or network printer.
pe.PrintReport(@"\jacc-fs120S2500 PCL IT");
}
}

class PrintExample
{
ReportingService rs;
private byte[][] m_renderedReport;
private Graphics.EnumerateMetafileProc m_delegate = null;
private MemoryStream m_currentPageStream;
private Metafile m_metafile = null;
int m_numberOfPages;
private int m_currentPrintingPage;
private int m_lastPrintingPage;

public PrintExample()
{
// Create proxy object and authenticate
Console.WriteLine("Authenticating to the Web service...");
rs = new ReportingService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
}

public byte[][] RenderReport(string reportPath)
{
// Private variables for rendering
string deviceInfo = null;
string format = "IMAGE";
Byte[] firstPage = null;
string encoding;
string mimeType;
Warning[] warnings = null;
ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
Byte[][] pages = null;

// Build device info based on the start page
deviceInfo =
String.Format(@"<DeviceInfo><OutputFormat>{0}</OutputFormat></DeviceInfo>", "emf");

//Exectute the report and get page count.
try
{
// Renders the first page of the report and returns streamIDs for
// subsequent pages
firstPage = rs.Render(
reportPath,
format,
null,
deviceInfo,
null,
null,
null,
out encoding,
out mimeType,
out reportHistoryParameters,
out warnings,
out streamIDs);

// The total number of pages of the report is 1 + the streamIDs
m_numberOfPages = streamIDs.Length + 1;
pages = new Byte[m_numberOfPages][];

// The first page was already rendered
pages[0] = firstPage;

for (int pageIndex = 1; pageIndex < m_numberOfPages; pageIndex++)
{
// Build device info based on start page
deviceInfo =
String.Format(@"<DeviceInfo><OutputFormat>{0}</OutputFormat><StartPage>{1}</StartPage></DeviceInfo>",
"emf", pageIndex+1);
pages[pageIndex] = rs.Render(
reportPath,
format,
null,
deviceInfo,
null,
null,
null,
out encoding,
out mimeType,
out reportHistoryParameters,
out warnings,
out streamIDs);
}
}

catch (SoapException ex)
{
Console.WriteLine(ex.Detail.InnerXml);
}

catch (Exception ex)
{
Console.WriteLine(ex.Message);
}

finally
{
Console.WriteLine("Number of pages: {0}", pages.Length);
}

return pages;
}


public bool PrintReport(string printerName)
{
this.RenderedReport = this.RenderReport("/SampleReports/Company Sales");
try
{
// Wait for the report to completely render.
if(m_numberOfPages < 1)
return false;
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.MaximumPage = m_numberOfPages;
printerSettings.MinimumPage = 1;
printerSettings.PrintRange = PrintRange.SomePages;
printerSettings.FromPage = 1;
printerSettings.ToPage = m_numberOfPages;
printerSettings.PrinterName = printerName;
PrintDocument pd = new PrintDocument();
m_currentPrintingPage = 1;
m_lastPrintingPage = m_numberOfPages;
pd.PrinterSettings = printerSettings;

// Print report
Console.WriteLine("Printing report...");
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
}

catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
// Clean up goes here.
}

return true;
}

private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
ev.HasMorePages = false;
if (m_currentPrintingPage <= m_lastPrintingPage && MoveToPage(m_currentPrintingPage))
{
// Draw the page
ReportDrawPage(ev.Graphics);
// If the next page is less than or equal to the last page,
// print another page.
if (++m_currentPrintingPage <= m_lastPrintingPage)
ev.HasMorePages = true;
}
}

// Method to draw the current emf memory stream
private void ReportDrawPage(Graphics g)
{
if(null == m_currentPageStream || 0 == m_currentPageStream.Length || null ==m_metafile)
return;
lock(this)
{
// Set the metafile delegate.
int width = m_metafile.Width;
int height= m_metafile.Height;
m_delegate = new Graphics.EnumerateMetafileProc(MetafileCallback);
// Draw in the rectangle
Point destPoint = new Point(0, 0);
g.EnumerateMetafile(m_metafile,destPoint , m_delegate);
// Clean up
m_delegate = null;
}
}

private bool MoveToPage(Int32 page)
{
// Check to make sure that the current page exists in
// the array list
if(null == this.RenderedReport[m_currentPrintingPage-1])
return false;
// Set current page stream equal to the rendered page
m_currentPageStream = new MemoryStream(this.RenderedReport[m_currentPrintingPage-1]);
// Set its postion to start.
m_currentPageStream.Position = 0;
// Initialize the metafile
if(null != m_metafile)
{
m_metafile.Dispose();
m_metafile = null;
}
// Load the metafile image for this page
m_metafile = new Metafile((Stream)m_currentPageStream);
return true;
}

private bool MetafileCallback(
EmfPlusRecordType recordType,
int flags,
int dataSize,
IntPtr data,
PlayRecordCallback callbackData)
{
byte[] dataArray = null;
// Dance around unmanaged code.
if (data != IntPtr.Zero)
{
// Copy the unmanaged record to a managed byte buffer
// that can be used by PlayRecord.
dataArray = new byte[dataSize];
Marshal.Copy(data, dataArray, 0, dataSize);
}
// play the record.
m_metafile.PlayRecord(recordType, flags, dataSize, dataArray);

return true;
}

public byte[][] RenderedReport
{
get
{
return m_renderedReport;
}
set
{
m_renderedReport = value;
}
}
}
}


Thanks
Tom

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved