Implement reporting services projects in multiple languages

Source: Internet
Author: User

Since the release of SQL Server 2005, we have another option for developing report projects: reporting services.
For work reasons, you have been familiar with developing report projects using the reporting services technology for a long time. It can be used in SQL Server 2005/2008. SQL Server 2000 also has reporting services, which are rarely used. Even if you have not purchased the SQL Server 2005 license, you can use this technology to use simple and lightweight client reports (rdlc ).

Recently, I was asked how to implement multiple languages in reporting services. After some exploration, find an effective solution.
The simplest way is to create the same report file for each language, but to replace all the labels in it with the text in this language. For example, to create a report in both Chinese and English languages, create two report files, customer. RDL and customer. zh-cn.rdl.
On the report Presentation client, select different reports based on the user's language offset. This method is simple and feasible, but it will lead to repetition. Modify the format of a report. You must also modify the format of another report, which is inconvenient to maintain.

The following describes another method to create a non-multilingual report using a file.
Open bids, create a Reporting Services Project, and add a report.

The technology involved in making reports is not complex. We focus on how to implement multi-language production.
This report reads the customer table of the SQL Server northwind database and uses the table to present it in the report.

Then, design the report columns to present the corresponding data.

Here, I designed two labels to display different language characters based on the language offset of the client.
One is the report title, the customer report is the customer report in Chinese, and the other is the grand total, expressed in Chinese as the total
Note: I have not implemented labels such as order ID and employee ID in many languages. The situation is similar.
Preview the report to make sure that the report design is correct.

The following describes how to develop resource files. First, add a class library project of uiresx to the project. Here, I use a new solution, because SQL Server 2005 bids uses Visual Studio 2005, while my computer only installs Visual Studio 2008. The two cannot be integrated into a development environment, and the solution version is not compatible.

I only create resource files in two languages (En-US, ZH-CN) and use stringresources2.
If you are not familiar with this tool, please refer to my article
Application open-source project stringresourcetool2 to implement. Net multi-language solutions

The content of the en-US file is as follows:

En-CN file content is as follows

Add a signature to the class library to facilitate deployment in GAC for reference in the report.

In this way, the resource file is ready. Return to the report project and make two small changes.
1) AddProgramSet reference. In the report --> report Properties dialog box, add a reference to the resource file assembly.

Because it is a static property, you do not need to add instance variables.
2) Enter report. uiresx. sr. orderreport where the report name is displayed.
Enter = report. uiresx. sr. grandtotal

This is all we need to do. We do not need to set the language attribute of the report. For example, in my computer, the language is not set to user! Language can also run normally.

The report is created. Deploy the report first. Open the browser and view the report in the report Browser

If no results are displayed, deploy the uiresx resource file library and copy report. uiresx. dll and ZH-CN/report. uiresx. Resources. DLL to the directory where the report server is located. In my computer, this directory is
D: \ Program Files \ Microsoft SQL Server \ mssql.2 \ Reporting Services \ reportserver \ bin

To more accurately control the report display effect, let's create a website to display our reports.
Create an ASP. NET web site and add a page file, as shown in figure

First, design the page layout. I put the user language selection and report display on the same page. Generally, we should allow the user to select the language offset at the place where the user logs in. The page layout is as follows:

Return to the Code to see how the report is referenced.
Protected void btnviewreport_click (Object sender, eventargs E)
{
// Set language
String Language = ddllanguage. selectedvalue;
Thread. currentthread. currentuiculture = new system. Globalization. cultureinfo (language );
Thread. currentthread. currentculture = new system. Globalization. cultureinfo (language );
Title = report. uiresx. sr. orderreport;
// Set the report
Reportviewer1.processingmode = Microsoft. Reporting. webforms. processingmode. Remote;
Reportviewer1.serverreport. reportserverurl = new system. Uri ("http: // localhost/reportserver ");
Reportviewer1.serverreport. reportpath = "/test/order ";
Reportviewer1.serverreport. Refresh ();
}
Run the website and select Chinese. The effect is as follows:

Select English again. The effect is as follows:

After writing reporting services, I suddenly wanted to know how to implement multi-language in the crystal report. At the time of my graduation, my company had a lot of projects and I learned Crystal Reports. Unfortunately, my work in the past few years was not used and I almost forgot everything.
Today is another weekend. Have a good weekend.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.