简体   繁体   中英

Print a report Multiple times, (SSRS reporting services)

I am currently working on SSRS reports 2008 displaying them in Website created in VS 2010 ie, ASP.NET 4.0 C#.

My current issue is I have a report with only a Letterhead on it. And this report page needs to be printed multiple times based on the value in TextBox as shown的值多次打印,如图在此处输入图像描述


To be a bit descriptive:

When the user enters the value in Number of Pages TextBox and clicks on this Print button icon, he/she lands on the page with ReportViewer control on it, displaying the report.This report has only a letterhead in the PageHeader of the report and here this report will be printed by clicking the default print button of ReportViewer control.

But, I am unable to figure out, how to print this report page as many times as there will be the value in the No of Pages TextBox (as shown in the fig.)
(The Letterhead of the company to be shown in report is retrieved from database through a Stored Procedure)

I tried a lot of Googling but to no avail.

Create a new report. This report should have 1 parameter called "number of copies" (or equivalent). It should also have a Tablix with 1 column and no borders, inside the cell insert a sub report pointing to the report with the letterhead.

Your dataset query should be something like this:

WITH dataset AS (
   SELECT 1 AS ID UNION ALL 
   SELECT ID + 1 FROM dataset WHERE ID < @Param
)
SELECT ID 
FROM dataset --edit: obviously I was missing the table
OPTION (MAXRECURSION 0)

Then on your tablix, use this dataset, group by ID and on the group properties select "Page Breaks"->"Between each instance of a group".

If I understood your question correctly, this should do the trick.

Expanding on Joao's solution (thanks for that) you can also do it without a subreport by joining the counter table to the actual data you want to display in the dataset.

  1. Add a Copies integer parameter with a default value of 1

  2. Update your dataset to include the counter and join

     -- Generate a table with @Count rows WITH dataset AS (SELECT 1 AS Copy UNION ALL SELECT Copy + 1 AS Expr1 FROM dataset AS dataset_2 WHERE (Copy < @Copies)) SELECT * FROM dataset INNER JOIN ( -- The primary data to repeat SELECT * FROM MyTable WHERE Id = @IdParam -- End ) d ON 1=1 OPTION (MAXRECURSION 0)
  3. Add/update your row group to group on [Copy]

    在此处输入图像描述

  4. Set the row group page breaks to 'between each instance'

    在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM