Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Fri Jan 14, 2022 4:51 pm

Hi,

I am experiencing issues with RichText and Workbook.DefaultFontName in the latest Spire.Office 6.12.1 targeting .NET 5.0. I was able to create a minimum example code:
Code: Select all
            using (var workbook = new Workbook())
            {
                workbook.DefaultFontName = "Calibri Light";
                workbook.DefaultFontSize = 14;

                workbook.Worksheets.Clear();
                var worksheet = workbook.Worksheets.Add("test");

                worksheet.Range[1, 1].Text = "Some normal text";

                var boldFont = workbook.CreateFont();
                boldFont.IsBold = true;
                worksheet.Range[2, 1].RichText.Text += "regular bold regular";
                worksheet.Range[2, 1].RichText.SetFont(8, 11, boldFont);

                worksheet.Range.Style.VerticalAlignment = VerticalAlignType.Center;

                workbook.SaveToFile("text.xlsx", ExcelVersion.Version2016);
            }


when I open the created file I get the following situation, where the first cell has font Arial with size 10, as well as the first part of the richtext:
Excel bad.PNG
Excel bad.PNG (7.48 KiB) Viewed 499 times

Interestingly, if I change the richtext to "regular bold" (removing the last "regular"), the problem goes away:
Excel good.PNG
Excel good.PNG (7.74 KiB) Viewed 499 times

It seems that the problem only occurs when the endPost argument of the RichText.SetFont(int startPos, int endPost, ExcelFont font) method is not equal to the full length of the richtext.

Do you have any workaround?
I also tried adding
Code: Select all
var regularFont = workbook.CreateFont();
worksheet.Range[2, 1].RichText.SetFont(13, 19, regularFont);

but it does not solve the problem.

Thanks,

Francesco

f.mazzurco
 
Posts: 13
Joined: Thu Aug 30, 2018 7:57 am

Mon Jan 17, 2022 3:49 am

Hello,

Thanks for your inquiry!

I have reproduced your issue and logged it in our issue tracking system with the ticket SPIREXLS-3649 for further investigation.

We will let you know if there is any update. Sorry for the inconvenience caused.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Tue Jan 18, 2022 10:26 am

Ok, thanks.
I would be willing to test any alpha or beta release if it can speed up the process.

Francesco

f.mazzurco
 
Posts: 13
Joined: Thu Aug 30, 2018 7:57 am

Wed Jan 19, 2022 1:43 am

Hello Francesco,

Okay, once there is any good news, we will notify you immediately. Sorry for the inconvenience caused.

Thanks again for your patience.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Wed Mar 23, 2022 9:10 am

Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.Office Platinum(Hotfix) Version:7.3.2 which fixes the issue with SPIREXLS-3649.
Please download the new version from the following links to test.

Website link: https://www.e-iceblue.com/Download/download-office-for-net-now.html
Nuget link:
https://www.nuget.org/packages/Spire.Office/7.3.2
https://www.nuget.org/packages/Spire.Officefor.NETStandard/7.3.2

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Tue Mar 29, 2022 9:28 am

Hi,

Thanks, I will try it and let you know if I encounter any issue.
In any case, in the meantime I have been using the new Range.HtmlString property which works great.

Thanks again,

Francesco

f.mazzurco
 
Posts: 13
Joined: Thu Aug 30, 2018 7:57 am

Tue Mar 29, 2022 9:32 am

Hello,

You are welcome.
Looking forward to your test feedback.
Have a nice day!

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1648
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS