Bug 57780 - Exception java.lang.IllegalArgumentException when calling XSSFRichTextString#applyFont on XSSFRichTextString containing text string like _xNNNN_
Summary: Exception java.lang.IllegalArgumentException when calling XSSFRichTextString#...
Status: RESOLVED DUPLICATE of bug 57008
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.8-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2015-03-30 13:50 UTC by carlo.dellacqua
Modified: 2015-04-20 20:40 UTC (History)
0 users

Test classes and description of the results (7.35 KB, application/x-7z-compressed)
2015-03-30 13:50 UTC, carlo.dellacqua

Note You need to log in before you can comment on or make changes to this bug.
Description carlo.dellacqua 2015-03-30 13:50:44 UTC
Created attachment 32622 [details]
Test classes and description of the results

We use POI 3.8-Final but the problem occurs also with 3.11.
We need the insert in cell comments strings with different font type and the code used is the following:

XSSFWorkbook workbook = new XSSFWorkbook();

XSSFFont font = workbook.createFont();

XSSFCreationHelper creationHelper = workbook.getCreationHelper();     
XSSFSheet sheet = workbook.createSheet();
XSSFDrawing drawing = sheet.createDrawingPatriarch();     
XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 2, 2, 5, 5); 

XSSFRow row_0 = sheet.createRow(0);

XSSFCell cell_0_0 = row_0.createCell(0);
cell_0_0.setCellValue("Cell 0:0");
XSSFComment comment_0_0 = drawing.createCellComment(anchor);
XSSFRichTextString rts_0_0 = creationHelper.createRichTextString("RichString 0:0 _x0046_");
try {
} catch(java.lang.IllegalArgumentException iae) {
	System.out.println("testXSSF: Comment 0:0 - "+iae);

returns the Exception.

To avoid the Exeception we have capitalized the text changing it from _x0046_ to _X0046_ (using Pattern/Matcher).

Has to be noticed that HSSF (file extension .xls) manages without problem the text string.

Attached you can find a test class (Text_xNNNN_applyFont) and the created Excel files.
Comment 1 Dominik Stadler 2015-04-20 20:40:06 UTC
I think this is basically a duplicate of bug 57008, which we closed as WONTFIX, see the comments further down in that bug for some explanation.

*** This bug has been marked as a duplicate of bug 57008 ***