问题
When exporting a multi-page report from SQL Server 2008 Reporting Services to Excel, by default, pages in the report created by a page break are sent to separate worksheets in the Excel file.
While this is fine most of the time - sometimes it's not. Right now, I'd like to be able to prevent those page breaks from causing additional worksheets to be created - I really would like to export all my pages into a single Excel worksheet and basically just ignore the page breaks (or replace them with --------
or something like that).
So when exporting my list of locations for a customer to PDF, I would like to put each location on a separate page (the location details are rendered out as a subreport, inside a grouping on the main report). But if I export to Excel, I'd like to keep all data together in one worksheet.
I did find that the grouping on the main report contains a "Page Breaks: Between" setting - but I can't seem to find a way to dynamically (e.g. by means of a parameter) change that so that I could turn it on for PDF rendering, and OFF for Excel exports.
How can I do that - if at all? Any ideas? I can't seem to find any properties to set or hooks to hook into to influence the Export export from SSRS...
回答1:
You can condition page breaks with a small rectangle that has a page break at the end, which you then hide when you don't want a page break. If you condition the Hidden attribute as =Globals!RenderFormat.Name = "EXCEL"
, the rectangle will be hidden in Excel exports and the page break won't happen.
来源:https://stackoverflow.com/questions/22061198/suppressing-page-breaks-upon-exporting-a-reporting-services-report-to-excel