考慮以下數據源:如何在不丟失結構的情況下將SSRS矩陣導出爲CSV?
declare @Test table (EmpId int, ProdId int, Sold int)
insert @Test (EmpId, ProdId, Sold) values (1, 1, 1)
insert @Test (EmpId, ProdId, Sold) values (1, 2, 2)
insert @Test (EmpId, ProdId, Sold) values (1, 3, 3)
insert @Test (EmpId, ProdId, Sold) values (1, 4, 4)
insert @Test (EmpId, ProdId, Sold) values (2, 1, 5)
insert @Test (EmpId, ProdId, Sold) values (2, 2, 6)
insert @Test (EmpId, ProdId, Sold) values (2, 3, 7)
insert @Test (EmpId, ProdId, Sold) values (2, 4, 8)
select * from @Test
我創建一個SQL Server報表服務(SSRS)2008 R2包含配置這樣一個矩陣報告:
| | [ProdId] |
| [EmpId] | [Sum(Sold)] |
其中,在預覽模式下,呈現以下內容(如預期):
| | 1 | 2 | 3 | 4 |
| 1 | 1 | 2 | 3 | 4 |
| 2 | 5 | 6 | 7 | 8 |
但是,當我將其導出爲CSV我得到這個:
| EmpId | ProdId | Sold |
| 1 | 1 | 1 |
| 1 | 2 | 2 |
| 1 | 3 | 3 |
| 1 | 4 | 4 |
| 2 | 1 | 5 |
| 2 | 2 | 6 |
| 2 | 3 | 7 |
| 2 | 4 | 8 |
換句話說,當我導出到CSV時,我失去了矩陣佈局,每行數據都呈現爲一行CSV。請注意,如果我導出到Excel,報表按預期工作,所以此問題似乎僅限於CSV。我曾嘗試將矩陣重新組織爲表格內的表格,但這並不能解決問題。有什麼建議麼?