While set the RTF text in the text box control the specified Alignment is not working. This issue included in both base and portable. In the ASP.NET Core, the exception “System.ArgumentException: ''Windows-1252' is not a supported encoding name.'” throws while set the RTF text in the textbox. So we have to fix these issues in both portable and base projects.
Code Snippet:
ExcelEngine excel = new ExcelEngine();
var application = excel.Excel;
application.DefaultVersion = ExcelVersion.Excel2010;
var workbook = application.Workbooks.Create(1);
var sheet = workbook.Worksheets[0];
var textBox = sheet.TextBoxes.AddTextBox(2, 2, 100, 200);
textBox.RichText.RtfText = @"{\rtf1\ansi\ansicpg1250\deff0\nouicompat\deflang1029{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}}
\viewkind4\uc1 \pard\qc\f0\fs20 One paragraph.}";
var textBox2 = sheet.TextBoxes.AddTextBox(10, 2, 100, 200);
textBox2.RichText.RtfText = @"{\rtf1\ansi\ansicpg1250\deff0\nouicompat\deflang1029{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}}
\viewkind4\uc1
\pard\qc\f0\fs20 First paragraph.\par
Second paragraph.\par
Third paragraph.\par}";
using (FileStream fs = File.Create(outputFilename))
{
workbook.SaveAs(fs);
}
Process.Start(outputFilename);