Reporting Service 设置中文Bar

来源:互联网 发布:宏观经济数据公布时间 编辑:程序博客网 时间:2024/05/16 14:13
客户端浏览器在查看报表的时候,报表信息是中文,但是报表上面的工具栏确是英文的。
尝试了装.net2 Framework中文语言包、ReportView中文语言包、程序中采用中文属性(AssemblyInfo.cs文件中设置[assembly: NeutralResourcesLanguageAttribute("zh-CN")])、安装windows最新补丁等方法,都没有办法实现。最后在msdn看到了Microsoft.Reporting.WebForms中一个接口IReportViewerMessages的介绍:使应用程序可以提供自定义的用户界面消息。因此尝试用实现此接口的方法来实现。
在App_Code目录下新建ReportViewerMessagesZhcn.cs类,让他实现IReportViewerMessages接口,代码如下:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Reporting.WebForms;

namespace AdminConsole.App_Code
{
    public class ReportViewerMessagesZhcn : IReportViewerMessages
    {
    
        #region IReportViewerMessages Members
        public string BackButtonToolTip
        {
            get { return ("后退"); }
        }

        public string ChangeCredentialsText
        {
            get { return ("更改"); }
        }

        public string ChangeCredentialsToolTip
        {
            get { return ("ChangeCredentialsToolTip."); }
        }

        public string CurrentPageTextBoxToolTip
        {
            get { return ("当前页"); }
        }

        public string DocumentMap
        {
            get { return ("文档视图"); }
        }

        public string DocumentMapButtonToolTip
        {
            get { return ("文档视图."); }
        }

        public string ExportButtonText
        {
            get { return ("导出"); }
        }

        public string ExportButtonToolTip
        {
            get { return ("导出"); }
        }

        public string ExportFormatsToolTip
        {
            get { return ("选择格式."); }
        }

        public string FalseValueText
        {
            get { return ("不正确的值."); }
        }

        public string FindButtonText
        {
            get { return ("查找"); }
        }

        public string FindButtonToolTip
        {
            get { return ("查找"); }
        }

        public string FindNextButtonText
        {
            get { return ("下一个"); }
        }

        public string FindNextButtonToolTip
        {
            get { return ("查找下一个"); }
        }

        public string FirstPageButtonToolTip
        {
            get { return ("第一页"); }
        }

        public string InvalidPageNumber
        {
            get { return ("页面数不对"); }
        }

        public string LastPageButtonToolTip
        {
            get { return ("最后一页"); }
        }

        public string NextPageButtonToolTip
        {
            get { return ("下一页"); }
        }

        public string NoMoreMatches
        {
            get { return ("无匹配项"); }
        }

        public string NullCheckBoxText
        {
            get { return ("空值"); }
        }

        public string NullValueText
        {
            get { return ("空值"); }
        }

        public string PageOf
        {
            get { return ("页"); }
        }

        public string ParameterAreaButtonToolTip
        {
            get { return ("参数设置"); }
        }

        public string PasswordPrompt
        {
            get { return ("PasswordPrompt"); }
        }

        public string PreviousPageButtonToolTip
        {
            get { return ("上一页"); }
        }

        public string PrintButtonToolTip
        {
            get { return ("打印"); }
        }

        public string ProgressText
        {
            get { return ("正在生成报表......"); }
        }

        public string RefreshButtonToolTip
        {
            get { return ("刷新"); }
        }

        public string SearchTextBoxToolTip
        {
            get { return ("查找"); }
        }

        public string SelectAValue
        {
            get { return ("SelectAValue"); }
        }

        public string SelectAll
        {
            get { return ("全选"); }
        }

        public string SelectFormat
        {
            get { return ("选择格式"); }
        }

        public string TextNotFound
        {
            get { return ("未找到"); }
        }

        public string TodayIs
        {
            get { return ("TodayIs"); }
        }

        public string TrueValueText
        {
            get { return ("TrueValueText"); }
        }

        public string UserNamePrompt
        {
            get { return ("UserNamePrompt"); }
        }

        public string ViewReportButtonText
        {
            get { return ("查看报表"); }
        }

        public string ZoomControlToolTip
        {
            get { return ("缩放"); }
        }

        public string ZoomToPageWidth
        {
            get { return ("页宽"); }
        }

        public string ZoomToWholePage
        {
            get { return ("整页"); }
        }

        #endregion

    }
}

最后在web.config中设置该类对ReportViewer的控制:

在 <appSettings> 节中添加 ReportViewerMessages 属性,代码如下:
<appSettings>
    <add key="ReportViewerMessages" value="AdminConsole.App_Code.ReportViewerMessagesZhcn,App_Code" />
</appSettings>


编译发布,最后测试结果为工具栏显示为中文,问题得到解决。

遗留问题:导出的格式下拉框还是英文,打印对话框也是英文。

欢迎各位来交流,寻求遗留问题的解决方案。

以下为最终解决方案:

...................

<globalization   fileEncoding= "utf-8"   culture="zh-cn"   uiCulture= "zh-cn"/>

</system.web>

原创粉丝点击