We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cell comment text appears to be bold and italic (#1002)

Hi,

I have an Excel file with a comment in a cell. After setting font color for that comment, text of the comment unexpectedly becomes bold and italic. Can you help me with this?

Workbook workbook = new Workbook("BRP_StandartGroup_Application_documents.xls");
Worksheet worksheet = workbook.getWorksheets().get(0);
Shape shapeComment = worksheet.getShapes().get(0);
Font font = shapeComment.characters(0, 38).getFont();
Color fontColor = font.getColor();
Color color = Color.fromArgb(fontColor.getR(), fontColor.getG(), fontColor.getB());
font.setColor(color);
workbook.save("BRP_StandartGroup_Application_documents-target.xls");

Version of aspose.cells for Java I’m using is 16.11.0.
Excel file and screenshots are attached to the post.

cellCommentBecomesBoldItalic.zip (54.3 KB)

Regards,
Zeljko

@Zeljko,

Thanks for the sample code and template file with screenshots.

Please try our latest version/fix: Aspose.Cells for Java (Latest Version)

I have tested your scenario/case a bit using your sample code and it works fine.

Let us know if you still find any issue.

Hi,

thanks for your answer. I tested the scenario using the latest Aspose.Cells for Java (17.8.6), but text in cell comment still becomes bold and italic. Also, I noticed that aspose doesn’t see that comment as bold and italic (checked with assertEquals), but in excel file it is bold and italic, like in screenshot.

        Workbook workbook = new Workbook("BRP_StandartGroup_Application_documents.xls");
	Worksheet worksheet = workbook.getWorksheets().get(0);
	Shape shapeComment = worksheet.getShapes().get(0);
	Font font = shapeComment.characters(0,39).getFont();
	Color fontColor = font.getColor();
	Color color = Color.fromArgb(fontColor.getR(), fontColor.getG(), fontColor.getB());
	font.setColor(color);	
	workbook.save("BRP_StandartGroup_Application_documents-target.xls");
	workbook = new Workbook("BRP_StandartGroup_Application_documents-target.xls");
	worksheet = workbook.getWorksheets().get(0);
	shapeComment = worksheet.getShapes().get(0);
	font = shapeComment.characters(11, 28).getFont();
	assertEquals(false, font.isBold());
	assertEquals(false, font.isItalic());	

Regards,
Zeljko

@Zeljko,

I tried your code to generate the output file. Please find it attached and let us know if it is ok when opening the into MS Excel. I do not find bold/italic issue when opening the file into MS Excel 2007/2013.
file1.zip (6.7 KB)

Hi,

the file you sent me really don’t have bold/italic issue. I opened it with MS Excel 2013.
Output file which I get after generating my code is attached to the post. Please see it and let me know if you see bold/italic text in cell comment.

BRP_StandartGroup_Application_documents-target.xls.zip (6.6 KB)

@Zeljko,

Yes, I can see the bold/italic text in the cell comment by opening the file into MS Excel 2013. Please make sure that you are using v17.8.6 with the following sample code (which I used on my end), you should simply test in a separate Java program with pasting the following sample code only:
e.g
Sample code:

System.out.println(CellsHelper.getVersion());
Workbook workbook = new Workbook("BRP_StandartGroup_Application_documents.xls");
Worksheet worksheet = workbook.getWorksheets().get(0);
Shape shapeComment = worksheet.getShapes().get(0);
Font font = shapeComment.characters(0,39).getFont();
Color fontColor = font.getColor();
Color color = Color.fromArgb(fontColor.getR(), fontColor.getG(), fontColor.getB());
font.setColor(color);	
workbook.save("out1BRP_StandartGroup_Application_documents-target1.xls");

Hi Amjad,

Thank you for answer. I followed your instructions and tested code you’ve sent me. I made sure I use right version of aspose.cells (v17.8.6). This code really doesn’t lead to bold/italic issue. But besides this code, I set an aspose.cells licence too. When I run the code without setting licence, there is no bold/italic issue, but when I run the code with setting licence, bold/italic issue appears. I’m sending you a two codes, first with setting licence, other without setting it. Can you please check if you are getting bold/italic issue when running code with setting licence?

Code with setting licence (which leads to bold/italic issue):

File licenceFile = new File(/*path to licence*/);
assertTrue(licenceFile.exists());
InputStream licenceStream = new FileInputStream(licenceFile);
com.aspose.cells.License _cellsLicence = new com.aspose.cells.License();
_cellsLicence.setLicense(licenceStream);
licenceStream.close();
System.out.println(CellsHelper.getVersion());
Workbook workbook = new Workbook("BRP_StandartGroup_Application_documents.xls");
Worksheet worksheet = workbook.getWorksheets().get(0);
Shape shapeComment = worksheet.getShapes().get(0);
Font font = shapeComment.characters(0,39).getFont();
Color fontColor = font.getColor();
Color color = Color.fromArgb(fontColor.getR(), fontColor.getG(), fontColor.getB());
font.setColor(color);	
workbook.save("out1BRP_StandartGroup_Application_documents-target1.xls");

Code without setting licence (which doesn’t lead to bold/italic issue):

System.out.println(CellsHelper.getVersion());
Workbook workbook = new Workbook("BRP_StandartGroup_Application_documents.xls");
Worksheet worksheet = workbook.getWorksheets().get(0);
Shape shapeComment = worksheet.getShapes().get(0);
Font font = shapeComment.characters(0,39).getFont();
Color fontColor = font.getColor();
Color color = Color.fromArgb(fontColor.getR(), fontColor.getG(), fontColor.getB());
font.setColor(color);	
workbook.save("out1BRP_StandartGroup_Application_documents-target1.xls");

@Zeljko,

Thanks for providing us further details and sample code.

Finally, I am able to reproduce the issue as you mentioned only after setting the license before using my code, it works fine in evaluation mode (without setting a valid license) though. I found that comment text becomes bold/italic when updating comment’s color in license mode.

I have logged a ticket with an id “CELLSJAVA-42404” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

@Zeljko,

We did evaluate your issue further. Well, we cannot get the same result as viewed in MS Excel from your shared file. It is very strange that the font in MS Excel will be as as our API’s result if we only remove Revision settings of the file without other changes. We do not know why the Revision records change the font of the comment now. So, it will surely take more time to look into this issue.

Once have any new information, we will let you know here.

@Zeljko,

Just to inform you, we still could not find solution for it. The issue is too strange to us.
Sorry for inconvenience caused!