Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

How to use fonts having space in C# windows form to create excel workseet?

$
0
0

I am using an IEnumerable variable to create an Excel worksheet in C# windows form application. The problem is that I can set created worksheet font if the font name has 1 word, ex. 'IRNazanin', but for font name with space it doesn't work, ex. 'B Mitra'. My code is:

var wb = new XLWorkbook { RightToLeft = true };
var ws = wb.Worksheets.Add("Sick_Information");
ws.Columns().AdjustToContents();
ws.Style.Font.FontName = "B Mitra";

I have tried using font name:

  • without spase, ex. "BMitra"
  • with a hyphen, ex. "B-Mitra"
  • with underline, ex. "B_Mitra"
  • with extra single qout, ex. "'B Mitra'"

Still not working.
I am using ClosedXML.Excel library with ClosedXML version 0.94.2.0 and MS Office 2016. The excel will get the font name but won't apply it.

enter image description here

True B Mitra font is like this. (Changed manually)

enter image description here

The customer needs file with B Mitra font and Persian numbers. So I have no choice to change the font.


Viewing all articles
Browse latest Browse all 88854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>