Bold/Italic Style overflow in save as PDF for SetHeader contents for same column

When we are using PageSetup.SetHeader with script commands which includes multiple texts with different font style for same header column, Bold/Italic styles are being carry forwarded to next content even after giving normal style for those contents.

e.g.

PageSetup.SetHeader(0, "&"Arial,Bold"&15&K000000 Cell11 \n&"Arial,"&15&Kff0000 Cell12 \n&"Arial,Italic"&15&K000000 Cell13 Page &P of &N ");

In Above example Bold style is coming for Cell12 and Cell13 both texts. For Cell12 its showing Bold
and for Cell13 its showing Bold+Italic.

PageSetup.SetHeader(0, "&"Arial,Italic"&15&K000000 Cell31 \n&"Arial,"&15&K000000 Cell32 \n&"Arial,Bold"&15&K000000 Cell33 &P ");

In Above example Italic style is coming for Cell31 and Cell32 both texts. For Cell33 its showing Bold+Italic.

As per our observation Bold > Italic > Normal is being taking precedence over other styles in further texts of same Header Columns contents.

@sudhirdharani,

I tested your scenario/case using the following sample code with latest version/fix:
Aspose.Cells for .NET v24.2 (please try it if you are not already using it) and it works fine and as expected.
e.g.
Sample code:

// Instantiate a new workbook
Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];

worksheet.Cells["A10"].PutValue("testin..");

// Obtaining the reference of the PageSetup of the first worksheet
PageSetup pageSetup = worksheet.PageSetup;

// Setting left header
pageSetup.SetHeader(0, "&\"Arial,Bold\"&15&K000000 Cell11 \n&\"Arial,\"&15&Kff0000 Cell12 \n&\"Arial,Italic\"&15&K000000 Cell13 Page &P of &N ");

// Setting middle header
pageSetup.SetHeader(1, "&\"Arial,Italic\"&15&K000000 Cell31 \n&\"Arial,\"&15&K000000 Cell32 \n&\"Arial,Bold\"&15&K000000 Cell33 &P");

// Saving the Excel file
workbook.Save("g:\\test2\\out1.xlsx");

Please find attached the output Excel file for your reference. Please open the file into MS Excel and you may confirm that everything is ok for headers.
out1.zip (6.0 KB)

In the output Excel file, you may see left header which shows Cell11 is bold, Cell12 (red) is normal and Cell13 with page notations is italic and not bold. So, the header text seems ok.

In the output Excel file, middle header of the worksheet shows that Cell31 is italic, Cell32 is normal and Cell33 with page notation is bold and not italic.

If you still find any issue with latest version of the APIs, kindly zip and attach your output Excel file and complete sample code. Also, share your expected file with your desired headers applied. We will check your issue soon.

Thanks a lot Amjad.

Will try and come back to you shortly.

@sudhirdharani,

Sure, please take your time to try the latest version and suggested sample code. In case, you still find any issue, kindly do share the output Excel file, expected output file (you may add your desired header/footer for the worksheet(Page Setup) manually in MS Excel) and complete sample code. We will check your issue soon.

@sudhirdharani
By using the following sample code for testing, we found that bold and italic style were passed to the next paragraph of text in the PDF, which is inconsistent with the generated Excel. Please refer to the attachment. result.zip (53.6 KB)

The sample code as follows:

// Instantiate a new workbook
Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];

worksheet.Cells["A10"].PutValue("testin..");

// Obtaining the reference of the PageSetup of the first worksheet
PageSetup pageSetup = worksheet.PageSetup;

// Setting left header
pageSetup.SetHeader(0, "&\"Arial,Bold\"&15&K000000 Cell11 \n&\"Arial,\"&15&Kff0000 Cell12 \n&\"Arial,Italic\"&15&K000000 Cell13 Page &P of &N ");

// Setting middle header
pageSetup.SetHeader(1, "&\"Arial,Italic\"&15&K000000 Cell31 \n&\"Arial,\"&15&K000000 Cell32 \n&\"Arial,Bold\"&15&K000000 Cell33 &P");

// Saving the Excel file
workbook.Save(filePath + "out_net.xlsx");
workbook.Save(filePath + "out_net.pdf");

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-55201

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

We are also looking for provision where some text(s) in paragraph can also have Bold+Italic.
Each text can have their own Bold/Italic/Bold+Italic/Normal style without overflow issue in same paragraph of SetHeader in PDF save.

@sudhirdharani
Thank you for your feedback. Hopefully we could figure it out soon. Once we have an update on it, we will let you know.

@sudhirdharani,

This is to inform you that your issue (logged as “CELLSNET-55201”) has been resolved. The fix/enhancement will be included in the next release (Aspose.Cells v24.3) scheduled for release in the second week of March (next month). You will be notified when the next version is released.

We are using 17.12.0.0 version of Cell .Net lib in our product. Can you please provide fix on 17.12.0.0 version?

@sudhirdharani
Sorry, if you keep using an older version (Aspose.Cells 17.12), it won’t help you much. We couldn’t use the old version to evaluate the issue, nor could the old version include fixes or enhancements. All enhancements and fixes are based only on the latest API set.

In short, try to upgrade to the latest version and use it. Please let us know if you still find any issues. We will check it shortly.

The issues you have found earlier (filed as CELLSNET-55201) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

Any update on this ? is this also fixed in recent version ?

@sudhirdharani
The CELLSNET-55201 has been fixed in v24.3. Please download and test it.

ok, Can you please share some example code of it ? Looking for Bold+Italic use case without overflowing to next paragraph(s)

@sudhirdharani,

You can use the same sample code as we provided earlier. Now with Aspose.Cells for .NET v24.3, it works fine. Both output XLSX and PDF files are fine tuned as I tested. There is no overflow issue for bold+italic style attributes in headers. Here is the sample code (as use case) for your reference.
e.g.
Sample code:


// Instantiate a new workbook
Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];

worksheet.Cells["A10"].PutValue("testin..");

// Obtaining the reference of the PageSetup of the first worksheet
PageSetup pageSetup = worksheet.PageSetup;

// Setting left header
pageSetup.SetHeader(0, "&\"Arial,Bold\"&15&K000000 Cell11 \n&\"Arial,\"&15&Kff0000 Cell12 \n&\"Arial,Italic\"&15&K000000 Cell13 Page &P of &N ");

// Setting middle header
pageSetup.SetHeader(1, "&\"Arial,Italic\"&15&K000000 Cell31 \n&\"Arial,\"&15&K000000 Cell32 \n&\"Arial,Bold\"&15&K000000 Cell33 &P");

// Saving the Excel file
workbook.Save("g:\\test2\\out_net.xlsx");
workbook.Save("g:\\test2\\out_net.pdf");

Please try the above code segment with latest version and it will work fine, both output XLSX and PDF files are Ok.

thanks for this example. But I was looking for example where Bold+Italic can be set for same text

e.g. in this example please set Bold+Italic for “Cell11” , Normal for “Cell13” texts

pageSetup.SetHeader(0, "&"Arial,Bold"&15&K000000 Cell11 \n&"Arial,"&15&Kff0000 Cell12 \n&"Arial,Italic"&15&K000000 Cell13 Page &P of &N ");

@sudhirdharani,

Please use “Bold Italic” script/command for your needs.

Please try the following line of code for your needs:

pageSetup.SetHeader(0, "&\"Arial,Bold Italic\"&15&K000000 Cell11 \n&\"Arial,\"&15&Kff0000 Cell12 \n&\"Arial\"&15&K000000 Cell13 Page &P of &N ");

Hope, this helps a bit.