Changing default encoding of report (to display non-english text in reports) - solution found


Hi! Instead of russian words in reports I can see only strange symbold, even if regional settings in windows are set to russian. I tried it on english Windows 7, english XP SP3 and russian XP SP3. So I would like to know, where I can change font for reports?

file attachments


stefanomasseroli wrote May 11, 2010 at 1:15 PM

Hi! I had the same problem (also with non-cyrillic fonts), and I solved it in a very simple way, if you're following hansswolf's samples...

Try change the XAML filestream loading from this:
using (TextReader input = new StreamReader
      (new FileStream(filePath, FileMode.Open), Encoding.Default))
                reportDocument.XamlData = input.ReadToEnd();
to this:

using (FileStream fsXamlDocument = new FileStream(filePath, FileMode.Open, FileAccess.Read))
using (TextReader trXamlReader = new StreamReader(fsXamlDocument, Encoding.Default))
      // Read XAML content from file:
       reportDocument.XamlData = trXamlReader.ReadToEnd();

let me know if it works..

Boyd_Rice wrote May 11, 2010 at 2:25 PM

Thank you, I will try it. But I still need to know, how can I change default font and linespacing too, because official documents can use Times New Roman, 14, 1,5 only. Sorry for noob questions, but my head will blow soon :(

Boyd_Rice wrote May 14, 2010 at 9:25 AM

Hmm, I can't find code you posted in project.

But I found easy solution:

In WindowMain.xaml.cs of report sample project (Complex report in my case) one sthing should be changed:


StreamReader reader = new StreamReader(new FileStream(@"Templates\ComplexReport.xaml") to this:

StreamReader reader = new StreamReader(new FileStream(@"Templates\ComplexReport.xaml", FileMode.Open, FileAccess.Read),System.Text.Encoding.GetEncoding("windows-1251"));

All we need is just to set proper encoding in StreamReader constructor.

wrote May 14, 2010 at 9:28 AM

wrote Feb 21, 2013 at 10:38 PM