Wednesday, March 7, 2012

Report Bodytext in various Languages?

we need to format the bodytext on our reports in various languages.
We created a Table in SQL Server: ReportLocalizationBodytext
ID, strItem, strText, intLanguage
1, page, Seite, 1
2, page, Page, 2
etc... hundrets of entries
We created a Stored Procedure: usp_RPTS_GetBodytext
Input Parameters are:
@. intLanguageID, @.intReportID
to identify the current report and the desired Userlanguage
returned output-table of the stored procedure is:
Select strItem, strText from ReportLocalizationBodytext
where intReportID = @.intReportID and intLanguage = @.intLanguage
And now begins the headache:
Any one report contains around 20 diferent text labels which have to be
localized.
Currently we created one dataset for each text label.
E.g. the text "Page 1 of 9 pages" needs at least three labels to be
translated:
"Page", "of" and "pages"
so we have three Datasets like:
bdytxtPage, bdytxtOf and bdytxtPages
Each dataset receives the same 20 items and filters via a Report Definition
Language Datase Filter its one only text translation, like:
expression, operator, value
=Fields!strItem.Value, =, page
The final entry in the report-textbox is:
=First(Fields!strText.Value, "bdytxtPage") & Globals.PageNumber &
First(Fields!strText.Value, "bdytxtOf")
& Globals.TotalPages & First(Fields!strText.Value, "bdytxtPages")
In english there may be printed:
Page 3 of 9 pages
In German
Seite 3 von 9 Seiten
and so on
Question:
Wouldn't it be possible to create one lonely dataset e.g. Bodytext
and then derive each bdytxtText from this complete dataset rather than to go
out 20 times for each and every single word to retrieve each time the same
dataset, but filter it in a different way?Hello Henry,
I would like to suggest you to create a custom code in the reporting
service to retrive the data rather than use the Report Build in dataset to
get the data.
Writing Custom Code for Reporting Services
http://msdn2.microsoft.com/en-us/library/aa255830(sql.80).aspx
Hope this will be helpful.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================(This posting is provided "AS IS", with no warranties, and confers no
rights.)|||Wei Lu, thank you very much,
I've been thinking in writing custom code, as I already did in the past, but
I don't know, how to program it to retrieve a table and iterate through it to
get the text I need. Please give me some advice.
Sincerily, Henry
"Wei Lu [MSFT]" wrote:
> Hello Henry,
> I would like to suggest you to create a custom code in the reporting
> service to retrive the data rather than use the Report Build in dataset to
> get the data.
> Writing Custom Code for Reporting Services
> http://msdn2.microsoft.com/en-us/library/aa255830(sql.80).aspx
> Hope this will be helpful.
> Sincerely,
> Wei Lu
> Microsoft Online Community Support
> ==================================================> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>|||Hello Henry,
Why do store the information in a XML document?
I have tested in my side and successfully deployed it.
Here is the XML document:
=================<?xml version="1.0" encoding="utf-8" ?>
<Text>
<BodyTexts LanguageID="1">
<BodyText strItem="page" value ="Page"></BodyText>
<BodyText strItem="pages" value ="Pages"></BodyText>
</BodyTexts>
<BodyTexts LanguageID="2">
<BodyText strItem="page" value="Seite"></BodyText>
<BodyText strItem="pages" value="Seites"></BodyText>
</BodyTexts>
</Text>
=====================
Then, I developed a custom assembly. Here is the code in C#:
=============using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace XMLReportTest
{
public class XmlReportTestClass
{
private XmlDocument docx;
public XmlReportTestClass()
{
docx = new XmlDocument();
docx.Load(@."D:\DataLanguage.xml");
}
public string GetStrText(Int32 intLanguageID, string strItem)
{
XmlNode Node =docx.SelectSingleNode("/Text/BodyTexts[@.LanguageID=" +
intLanguageID.ToString() + "]");
XmlNode Node1 = Node.SelectSingleNode("./BodyText[@.strItem=\""
+ strItem + "\"]");
return Node1.Attributes["value"].Value;
}
}
}
==============
The GetStrText method will return the strText value by provide the
LanguageID and the strItem.
Then in the Report, you could add a Reference to the assembly. You could
then assign an instance name to the class and refer the instance in the
report design.
Here is the rdl file of the report
=============================<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefini
tion"
xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<BottomMargin>2.5cm</BottomMargin>
<RightMargin>2.5cm</RightMargin>
<PageWidth>21cm</PageWidth>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>21cm</InteractiveWidth>
<rd:GridSpacing>0.25cm</rd:GridSpacing>
<rd:SnapToGrid>true</rd:SnapToGrid>
<Body>
<ColumnSpacing>1cm</ColumnSpacing>
<ReportItems>
<Textbox Name="textbox2">
<Left>1.5cm</Left>
<Top>2.75cm</Top>
<ZIndex>1</ZIndex>
<Width>7.75cm</Width>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Height>0.75cm</Height>
<Value>=Code.doc.GetStrText(2,"pages")</Value>
</Textbox>
<Textbox Name="textbox1">
<Left>1.5cm</Left>
<Top>1cm</Top>
<rd:DefaultName>textbox1</rd:DefaultName>
<Width>7.75cm</Width>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Height>0.75cm</Height>
<Value>=Code.doc.GetStrText(1,"page")</Value>
</Textbox>
</ReportItems>
<Height>5cm</Height>
</Body>
<rd:ReportID>f3f844c0-d523-4e9a-9c50-7c22374abfe2</rd:ReportID>
<LeftMargin>2.5cm</LeftMargin>
<CodeModules>
<CodeModule>System.Xml, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</CodeModule>
<CodeModule>XMLReportTest, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null</CodeModule>
</CodeModules>
<Code />
<Width>16cm</Width>
<InteractiveHeight>29.7cm</InteractiveHeight>
<Classes>
<Class>
<ClassName>XMLReportTest.XMLReportTestClass</ClassName>
<InstanceName>doc</InstanceName>
</Class>
</Classes>
<Language>en-US</Language>
<TopMargin>2.5cm</TopMargin>
<PageHeight>29.7cm</PageHeight>
</Report>
==================
Please note, you need to copy the assembly to some place before to deploy
it to the report server and preview in the report designer.
To deploy a custom assembly in Reporting Services
Copy your custom assembly from your build location to the report server bin
folder or the Report Designer folder. The default location of the bin
folder for the report server is C:\Program Files\Microsoft SQL
Server\MSSQL.3\Reporting Services\ReportServer\bin. The default location of
the Report Designer is C:\Program Files\Microsoft Visual Studio
8\Common7\IDE\PrivateAssemblies.
Deploying a Custom Assembly
http://msdn2.microsoft.com/en-gb/library/ms155034.aspx
If you do not wants to use the xml to store the information, you could
modify my assembly to retrieve the data from the database and add the
assembly to the report.
Hope this will be helpful!
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi ,
How is everything going? Please feel free to let me know if you need any
assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment