https://bz.apache.org/bugzilla/show_bug.cgi?id=57780
Bug ID: 57780
Summary: Exception java.lang.IllegalArgumentException when
calling XSSFRichTextString#applyFont on
XSSFRichTextString containing text string like _xNNNN_
Product: POI
Version: 3.8-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
Created attachment 32622
--> https://bz.apache.org/bugzilla/attachment.cgi?id=32622&action=edit
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();
font.setFontName("Verdana");
font.setFontHeightInPoints((short)14);
font.setBoldweight((short)700);
font.setColor(IndexedColors.BLUE.getIndex());
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 {
rts_0_0.applyFont(font);
} catch(java.lang.IllegalArgumentException iae) {
System.out.println("testXSSF: Comment 0:0 - "+iae);
}
comment_0_0.setString(rts_0_0);
cell_0_0.setCellComment(comment_0_0);
and
rts_0_0.applyFont(font);
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.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]