导出Excel分页符

问题描述 投票:0回答:1

是否可以按页面名称为组的分组方式导出明智的输出,以页面名称为子组的分组方式导出输出excel。

尝试很少的选项,并且不适用于分页符和工作表名称。

分页符->组->之间分页符->子组->之间和结束。

使用以下数据集的预期输出:Excel中的5张纸。

  1. US-子组名称-Sheet1
  2. CA-子组名称-Sheet2
  3. [北美-具有汇总详细信息的组名称-sheet3
  4. FR-子组名称-sheet4
  5. 具有汇总详细信息的欧洲组名称-sheet5

样本数据集

Select 'Area-1' as Region, 'North America' as 'Group','US' as 'SubGroup','Northwest' as 'Detail',7887186.7882  'Sales'
union
Select 'Area-1', 'North America','US','Northeast',2402176.8476  
union
Select 'Area-1', 'North America','US','Central',3072175.118  
union
Select 'Area-1', 'North America','CA','Southwest',10510853.8739  
union
Select 'Area-1', 'North America','CA','Southeast',2538667.2515  
union
Select 'Area-1', 'North America','CA','Canada',6771829.1376  
union
Select 'Area-1', 'Europe','FR','Northwest',4772398.3078  
union
Select 'Area-1', 'Europe','FR','Northeast',3805202.3478  
union
Select 'Area-1', 'Europe','FR','Central',5012905.3656

enter image description here

enter image description here

预期输出:enter image description here

sql-server ssrs-2012 ssrs-tablix
1个回答
0
投票

我将尝试以不同的方式对数据进行分组,以使报表方面更容易。我把您的原始数据集,转储到临时表中,并像这样分组。

SELECT * INTO #t FROM (
Select 'Area-1' as Region, 'North America' as [Group],'US' as [SubGroup],'Northwest' as [Detail], 7887186.7882 as [Sales]
union
Select 'Area-1', 'North America','US','Northeast',2402176.8476  
union
Select 'Area-1', 'North America','US','Central',3072175.118  
union
Select 'Area-1', 'North America','CA','Southwest',10510853.8739  
union
Select 'Area-1', 'North America','CA','Southeast',2538667.2515  
union
Select 'Area-1', 'North America','CA','Canada',6771829.1376  
union
Select 'Area-1', 'Europe','FR','Northwest',4772398.3078  
union
Select 'Area-1', 'Europe','FR','Northeast',3805202.3478  
union
Select 'Area-1', 'Europe','FR','Central',5012905.3656
) q 

SELECT 
    [Region], [Group], [SubGroup], [Detail]
    , SUM(Sales) OVER(PARTITION BY [Group]) as ContinentSales
    , SUM(Sales) OVER(PARTITION BY [Group], [SubGroup]) as CountrySales
    , Sales as DetailSales
into #s
 FROM #t

SELECT DISTINCT Region, SubGroup as ReportGroup, Detail, DetailSales as Sales FROM #s
UNION ALL
SELECT DISTINCT Region, [Group], NULL, ContinentSales FROM #s

这将提供以下输出

enter image description here

然后您应该能够按报告组分组,并且也可以将其用作组属性中的页面名称。

© www.soinside.com 2019 - 2024. All rights reserved.