发布时间 : 2018-10-09 10:19:27.000|阅读 291 次
概述:本文介绍了在Stimulsoft Reports.Net中利用代码实现全球化语言报表。
相关链接:
【下载Stimulsoft Reports.Net最新版本】
此示例显示报表全球化的工作原理,该报表可以在多种文化中进行本地化。这是国际项目的一个重要特征,它提供了克服语言障碍的机会,可以用各种语言显示相同的报表。 例如,我们在列表中添加了几个语言文件。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Globalized_Reports.Default" %> <%@ Register assembly="Stimulsoft.Report.Web" namespace="Stimulsoft.Report.Web" tagprefix="cc1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Globalizad Reports</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Names="Arial" Font-Size="14px" Text="Select Country"></asp:Label> <br /> <asp:DropDownList ID="DropDownList1" runat="server" Width="150"> <asp:ListItem Value="fr-FR">France</asp:ListItem> <asp:ListItem Value="de-DE">Germany</asp:ListItem> <asp:ListItem Value="it-IT">Italy</asp:ListItem> <asp:ListItem Value="ru-RU">Russia</asp:ListItem> <asp:ListItem Value="es-ES">Spain</asp:ListItem> <asp:ListItem Value="en-GB">United Kingdom</asp:ListItem> <asp:ListItem Value="en-US">United States</asp:ListItem> </asp:DropDownList> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="View Report" onclick="Button1_Click" /> <br /> <br /> <cc1:StiWebViewer ID="StiWebViewer1" runat="server" /> </div> </form> </body> </html>
该button1_Click事件所选择的文化应用到报表。为此,使用GlobalizationManager类。
protected void Button1_Click(object sender, EventArgs e) { string appPath = Server.MapPath(string.Empty); string cultureName = DropDownList1.SelectedValue; // Get Report Data DataSet data = new DataSet(); data.ReadXml(appPath + "\\Data\\Demo.xml"); // Get Report StiReport report = new StiReport(); report.GlobalizationManager = new GlobalizationManager(new CultureInfo(cultureName)); report.RegData(data); report.Load(appPath + "\\Data\\SimpleList.mrt"); // Show Report StiWebViewer1.Report = report; }
示例代码的结果如下图所示:
购买Stimulsoft正版授权,请点击“咨询在线客服”哟!