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.
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.
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.
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.
@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
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.