locked
Multilanguage Reports RRS feed

  • Question

  • User1423141334 posted

    I am creating a multilanguage web-based system and my project need use multilanguage reports.

    How can I create multilanguage reports?

    I am looking for the possibility to make in Crytal Report or Reporting Services but I do not get anything.

    I can't use third party.
     
    What way can I do to make the multilanguage reports?
     
    Thanks for your help!
    Friday, July 10, 2009 8:37 AM

Answers

  • User1447851808 posted

    Hi 

     If you are using the Crystal report in VS 2003/2005 ( dont know if VS 2008 supports ), then there is no support for localization/globalization ( multilanguage ). But u can try like this: 


    VS 2003 --

    ' Include the namespaces

    Imports System.Reflection

    Imports System.Resources

    Imports System.Globalization

    ' Get the current culture from the configuration file

    Public CultureInfo As New CultureInfo(ConfigurationSettings.AppSettings("CurrentCulture").ToString())

    Public ResManager As ResourceManager = New ResourceManager("pro.Default",[Assembly].GetExecutingAssembly())

    ' Create a formula defintion variable
                  crxFormula = crReport.DataDefinition.FormulaFields(key)
                    crxFormula.Text = """" & m_Hastable.Item(key) & """"
                Next
                Dim oStream As New System.IO.MemoryStream
                'crReport.SetDatabaseLogon(ConfigurationSettings.AppSettings.Item("crLoginName"), ConfigurationSettings.AppSettings.Item("crLoginPassword"), ConfigurationSettings.AppSettings.Item("crServer"), "cvs")
                'DoCRLogin(crReport)
                If Session.Item("Print") = True Then
                    oStream = crReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
                    Response.Clear()
                    Response.Buffer = True
                    Response.ContentType = "application/pdf"
                    Response.BinaryWrite(oStream.ToArray())
                    Response.End()
                Else
                    crViewer.ReportSource = crReport

                End If


    Dim crxFormula As FormulaFieldDefinition

    ' Set the formula field that is on the report ( you can use the hashtable and collection together for multiple formula fields )

    crxFormula = crReport.DataDefinition.FormulaFields("formula_field_name")

    crxFormula.Text = ResManager.GetString("ALL_UNITS", CultureInfo)

    Dim oStream As New System.IO.MemoryStream

    oStream = crReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)

    Response.Clear()

    Response.Buffer = True

    Response.ContentType = "application/pdf"

    Response.BinaryWrite(oStream.ToArray())

    Response.End()

    VS 2005 --

    using CrystalDecisions.CrystalReports.Engine;

    using CrystalDecisions.Enterprise;

    using CrystalDecisions.Shared;

    using CrystalDecisions.ReportSource;

    using System.Reflection;

    using System.Globalization;

    using System.Threading;

    using System.Resources;


    ReportDocument myReportDoc = new ReportDocument();

    myReportDoc.Load(Server.MapPath("ReportFile/rptMyReport.rpt"));

    myReportDoc.SetDataSource(myDataSet);


    // Method1 - Using the formula field

    =========================================================================

    CultureInfo cultureInfo = new CultureInfo("en-US");

    myReportDoc.DataDefinition.FormulaFields["FF_ID"].Text = "'"+getResourceManager("FF_ID",cultureInfo)+"'";

    ==========================================================================


    // Method2 - Using Parameters

    =============================================================================

    ParameterFields MyParams=new ParameterFields();

    ParameterField MyParam=new ParameterField();

    MyParam.Name="@PF_Name";           

    ParameterDiscreteValue MyDiscreteParameterValue=new ParameterDiscreteValue();

    MyDiscreteParameterValue.Value="'"+getResourceManager("FF_ID",cultureInfo)+"'";;             

    MyParam.CurrentValues.Add(MyDiscreteParameterValue);

    MyParams.Add(MyParam);

    =============================================================================            

    CrystalReportViewer1.ParameterFieldInfo = MyParams;

    CrystalReportViewer1.ReportSource = myReportDoc;

    CrystalReportViewer1.DataBind();


    // Private Method

    public string getResourceManager(string key, CultureInfo culinfo)

    {

    Thread.CurrentThread.CurrentCulture = culinfo;

            Thread.CurrentThread.CurrentUICulture = culinfo;

            ResourceManager resourceManager = new ResourceManager("Resources.myResource", Assembly.Load("App_GlobalResources"));

            string value = string.Empty;

            value = (resourceManager.GetString(key, culinfo));

            return value;

    }



    Beacuse you have lots of fields on your report need to be globalized, so you can put the current language text into a hash table first. The key is the hash table should be same as that of the formula field or parameter on ther report. Then get all the keys in to a collection and iterate through one by one and set the text.

    Dim crxFormula As FormulaFieldDefinition

    m_Hastable = Session.Item("HashTable")

    Dim allKeys As System.Collections.ICollection = m_Hastable.Keys

    Dim key As String

    For Each key In allKeys

         crxFormula = crReport.DataDefinition.FormulaFields(key)

         crxFormula.Text = """" & m_Hastable.Item(key) & """"

    Next


    Thanks!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2009 9:58 AM

All replies

  • User1383809551 posted

     Hi,

    For multi language support you have to use resource files.

    See this link

    http://www.c-sharpcorner.com/UploadFile/mosessaur/aspnetlocalization02042006165851PM/aspnetlocalization.aspx?ArticleID=96602e53-0fb1-44ec-a67b-1c68b05eb2e1

    Thanks

    Friday, July 10, 2009 9:26 AM
  • User1447851808 posted

    Hi 

     If you are using the Crystal report in VS 2003/2005 ( dont know if VS 2008 supports ), then there is no support for localization/globalization ( multilanguage ). But u can try like this: 


    VS 2003 --

    ' Include the namespaces

    Imports System.Reflection

    Imports System.Resources

    Imports System.Globalization

    ' Get the current culture from the configuration file

    Public CultureInfo As New CultureInfo(ConfigurationSettings.AppSettings("CurrentCulture").ToString())

    Public ResManager As ResourceManager = New ResourceManager("pro.Default",[Assembly].GetExecutingAssembly())

    ' Create a formula defintion variable
                  crxFormula = crReport.DataDefinition.FormulaFields(key)
                    crxFormula.Text = """" & m_Hastable.Item(key) & """"
                Next
                Dim oStream As New System.IO.MemoryStream
                'crReport.SetDatabaseLogon(ConfigurationSettings.AppSettings.Item("crLoginName"), ConfigurationSettings.AppSettings.Item("crLoginPassword"), ConfigurationSettings.AppSettings.Item("crServer"), "cvs")
                'DoCRLogin(crReport)
                If Session.Item("Print") = True Then
                    oStream = crReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
                    Response.Clear()
                    Response.Buffer = True
                    Response.ContentType = "application/pdf"
                    Response.BinaryWrite(oStream.ToArray())
                    Response.End()
                Else
                    crViewer.ReportSource = crReport

                End If


    Dim crxFormula As FormulaFieldDefinition

    ' Set the formula field that is on the report ( you can use the hashtable and collection together for multiple formula fields )

    crxFormula = crReport.DataDefinition.FormulaFields("formula_field_name")

    crxFormula.Text = ResManager.GetString("ALL_UNITS", CultureInfo)

    Dim oStream As New System.IO.MemoryStream

    oStream = crReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)

    Response.Clear()

    Response.Buffer = True

    Response.ContentType = "application/pdf"

    Response.BinaryWrite(oStream.ToArray())

    Response.End()

    VS 2005 --

    using CrystalDecisions.CrystalReports.Engine;

    using CrystalDecisions.Enterprise;

    using CrystalDecisions.Shared;

    using CrystalDecisions.ReportSource;

    using System.Reflection;

    using System.Globalization;

    using System.Threading;

    using System.Resources;


    ReportDocument myReportDoc = new ReportDocument();

    myReportDoc.Load(Server.MapPath("ReportFile/rptMyReport.rpt"));

    myReportDoc.SetDataSource(myDataSet);


    // Method1 - Using the formula field

    =========================================================================

    CultureInfo cultureInfo = new CultureInfo("en-US");

    myReportDoc.DataDefinition.FormulaFields["FF_ID"].Text = "'"+getResourceManager("FF_ID",cultureInfo)+"'";

    ==========================================================================


    // Method2 - Using Parameters

    =============================================================================

    ParameterFields MyParams=new ParameterFields();

    ParameterField MyParam=new ParameterField();

    MyParam.Name="@PF_Name";           

    ParameterDiscreteValue MyDiscreteParameterValue=new ParameterDiscreteValue();

    MyDiscreteParameterValue.Value="'"+getResourceManager("FF_ID",cultureInfo)+"'";;             

    MyParam.CurrentValues.Add(MyDiscreteParameterValue);

    MyParams.Add(MyParam);

    =============================================================================            

    CrystalReportViewer1.ParameterFieldInfo = MyParams;

    CrystalReportViewer1.ReportSource = myReportDoc;

    CrystalReportViewer1.DataBind();


    // Private Method

    public string getResourceManager(string key, CultureInfo culinfo)

    {

    Thread.CurrentThread.CurrentCulture = culinfo;

            Thread.CurrentThread.CurrentUICulture = culinfo;

            ResourceManager resourceManager = new ResourceManager("Resources.myResource", Assembly.Load("App_GlobalResources"));

            string value = string.Empty;

            value = (resourceManager.GetString(key, culinfo));

            return value;

    }



    Beacuse you have lots of fields on your report need to be globalized, so you can put the current language text into a hash table first. The key is the hash table should be same as that of the formula field or parameter on ther report. Then get all the keys in to a collection and iterate through one by one and set the text.

    Dim crxFormula As FormulaFieldDefinition

    m_Hastable = Session.Item("HashTable")

    Dim allKeys As System.Collections.ICollection = m_Hastable.Keys

    Dim key As String

    For Each key In allKeys

         crxFormula = crReport.DataDefinition.FormulaFields(key)

         crxFormula.Text = """" & m_Hastable.Item(key) & """"

    Next


    Thanks!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2009 9:58 AM
  • User-1384762298 posted

    Sealed yes you can use

    http://www.codeproject.com/KB/reporting-services/MultiLanguageReportsInSSR.aspx

    Friday, July 10, 2009 10:03 AM