askm
askm

Reputation: 315

Arabic language in RDLC Reports asp.net mvc

I'm trying to export MS Word files, But i got small problem with word file when i export it, because the data that i stored it in database is written by Arabic letters, so it's RTL, then the letters appeared as separated letters, this is piece of exported file:

enter image description here

Controller Action:

 public ActionResult Report(string id)
    {



        LocalReport lr = new LocalReport();
        string path = Path.Combine(Server.MapPath("~/Report"), "Report1.rdlc");//Report1.rdlc is a tamplate exist in Report Folder.
        if (System.IO.File.Exists(path))
        {
            lr.ReportPath = path;
        }
        else
        {
            return View("Index");
        }
        List<Note> cm = new List<Note>();

            cm = db.Notes.ToList();

        ReportDataSource rd = new ReportDataSource("DataSet1", cm);
        lr.DataSources.Add(rd);
        string reportType = id;
        string mimeType;
        string encoding;
        string fileNameExtension;



        string deviceInfo =

        "<DeviceInfo>" +
        "  <OutputFormat>" + id + "</OutputFormat>" +
        "  <PageWidth>8.5in</PageWidth>" +
        "  <PageHeight>11in</PageHeight>" +
        "  <MarginTop>0.5in</MarginTop>" +
        "  <MarginLeft>1in</MarginLeft>" +
        "  <MarginRight>1in</MarginRight>" +
        "  <MarginBottom>0.5in</MarginBottom>" +
        "</DeviceInfo>";

        Warning[] warnings;
        string[] streams;
        byte[] renderedBytes;

        renderedBytes = lr.Render(
            reportType,
            deviceInfo,
            out mimeType,
            out encoding,
            out fileNameExtension,
            out streams,
            out warnings);


        return File(renderedBytes, mimeType);
    }

When i export files in PDF, xlsx, and PNG extensions, they work correctly. Someone tell me that problem could be related to UTF-8, is it possible?

Any Suggestion?

Upvotes: 0

Views: 3222

Answers (1)

askm
askm

Reputation: 315

Finally, i found out the solution.

go to design page of your report :

  1. Select (column, row, label, or what would you like).
  2. Go to properties.
  3. Go to Localization.
  4. Set Direction RTL.
  5. Set Language ar-sa (you can choose any language starts with ar e.g. ar-eg, ar-kw, or whatever you like).

enter image description here

Upvotes: 3

Related Questions