不,不幸的是,没有简单的方法可以做到这一点:-(我一直在努力让自己得到这个并且自己运行,但最后我所做的基本上是通过我希望在报告上显示的所有标签来自调用app(在我的例子中是一个ASP.NET应用程序).
另一种方法可能是将文本片段存储在SQL Server表中,并将数据源添加到报告中,以检索这些文本标签,然后将它们绑定到适当的控件.我尝试过类似的东西但却无法让自己发挥作用.
ASP.NET在资源方面的国际化程度非常高,但SSRS在尝试使其具有多语言意识时仍然非常混乱:-(
通过应用一个有趣的技巧,我设法通过.NET资源文件获得了多语言支持。每个报表控件都有一个未使用的属性,称为ValueLocId。使用此属性,可以指定每个控件要使用的资源名称。这里的想法是,您将遍历报表定义,查找设置了ValueLocID属性的控件。如果设置了属性,则用ValueLocID中指定的资源文本替换该控件的文本。所以基本上,这个想法是这样的:
请参阅下面的功能,该功能将完全执行我上面提到的功能。
Private Sub LocalizeReport()
Dim xmlDoc As XmlDocument = New XmlDocument
Dim asm As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()
'create in memory, a XML file from a embedded resource
Dim xmlStream As Stream = asm.GetManifestResourceStream(ReportViewer1.LocalReport.ReportEmbeddedResource)
Try
'Load the RDLC file into a XML doc
xmlDoc.Load(xmlStream)
Catch e As Exception
'HANDLE YOUR ERROR HERE
End Try
'Create an XmlNamespaceManager to resolve the default namespace
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(xmlDoc.NameTable)
nsmgr.AddNamespace("nm", "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition")
nsmgr.AddNamespace("rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner")
'IMPORTANT LINE BELOW
'YOU WILL NEED TO SET THIS TO YOUR RESOURCE MANAGER, OTHERWISE NOTHING WILL WORK
Dim rm As ResourceManager = New ResourceManager("Insurance.Subs.WinUI.Controls.Resources", asm)
'Loop through each node in the XML file, that has the ValueLOCId property set.
'Using this property as a workaround for localization support. The value specified in this
'property will determine what resource to use for translation.
Dim node As XmlNode
For Each node In xmlDoc.DocumentElement.SelectNodes(String.Format("//nm:{0}[@rd:LocID]", "Value"), nsmgr) 'XPath to LocID
Dim nodeValue As String = node.InnerText
If (String.IsNullOrEmpty(nodeValue) Or Not nodeValue.StartsWith("=")) Then
Try
Dim localizedValue As String = node.Attributes("rd:LocID").Value
'Get the resource via string
localizedValue = rm.GetString(localizedValue)
If Not String.IsNullOrEmpty(localizedValue) Then
'Set the text value - via the retrieved information from resource file
node.InnerText = localizedValue
End If
Catch ex As Exception
'handle error
End Try
End If
Next
ReportViewer1.LocalReport.ReportPath = String.Empty
ReportViewer1.LocalReport.ReportEmbeddedResource = Nothing
'Load the updated RDLC document into LocalReport object.
Dim rdlcOutputStream As StringReader = New StringReader(xmlDoc.DocumentElement.OuterXml)
Using rdlcOutputStream
ReportViewer1.LocalReport.LoadReportDefinition(rdlcOutputStream)
End Using
End Sub
Run Code Online (Sandbox Code Playgroud)