KB-Report Margin Changed After SQL Server 2000 Report Service SP2
| | 0 | | ![]() |
最近有台SQL Server 2000 Reporting Service主機在部署好報表後,才發現忘了上SP2。上完SP2,卻發現部分報表在列印時邊界設定變了,導致原本一頁要印完的報表印成兩頁。
Google了一下,找到這篇說明,原來SP2為了配合線上列印的Print Control,會在Publish時為報表補上Page Size, Margin等屬性設定,但在SP2之前Publish的報表沒有這些屬性,就會套用8.5" x 11"的紙張, 0.5"邊界的預設值,造成列印結果與原先設計有所出入。這個問題只要重新上傳Publish報表就可以解決,但如果已有成百上千張報表,全部Republish會讓人手軟吧!
該篇文章提供了一段Reporting Service Script(我又學到新東西了),可以透過Script一次Republish所有的報表:
Public Sub Main()
Dim definition As [Byte]() = Nothing
Dim item As CatalogItem = Nothing
Dim items() As CatalogItem = Nothing
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
items = rs.ListChildren("/", True)
For Each item In items
If item.Type = ItemTypeEnum.Report Then
Console.WriteLine("Republishing Report: {0}", item.Path)
definition = rs.GetReportDefinition(item.Path)
rs.SetReportDefinition(item.Path, definition)
End If
Next
End Sub
很多人應該跟我一樣,對Reporting Service Script Host很陌生。所以補充一下,執行的步驟是將以上的Code存成Republish.rss檔案,然後在安裝Reporting Service的主機,執行以下指令:
rs -i republish.rss -s http://locahost/reportserver
大功告成!
PS: 對Reprting Service Script Host有興趣的人,可以參考這篇文章。
Comments
Be the first to post a comment