https://issues.apache.org/bugzilla/show_bug.cgi?id=57294
Bug ID: 57294
Summary: RichText is converted to nomal text in SXSSF
Product: POI
Version: 3.10-FINAL
Hardware: PC
Status: NEW
Severity: major
Priority: P2
Component: SXSSF
Assignee: [email protected]
Reporter: [email protected]
I have used SXSSF to output Excel files (xlsx).
When I tried to write RichTextString in SXSSFCell, it was converted to normal
text in output file,
(just reflected one cell style to whole cell),
because it seems that SheetDataWriter.java does not support RichTextString.
Then, I tried to change method SheetDataWriter#writeCell according to the rules
of OOXML,
and it worked well in my environment.
Here is my code:
-----------------------------------------
SheetDataWriter.java
public void writeCell(int columnIndex, Cell, cell) throws IOException {
int celltype = cell.getCellType();
switch(celltype){
case Cell.CELL_TYPE_STRING:
// get RichTextString info
XSSFRichTextString richText = (XSSFRichTextString)
cell.getRichStringCellValue();
List<CTRElt> listElt = richText.getCTRst().getRList();
// write cell info to sheet.xml
String ref = new CellReferec(this._rownum,
columnIndex).formatAsString();
this._output.write("<c r=\"" + ref + "\"");
CellStyle cellStyle = cell.getCellStyle();
if(cellStyle.getIndex() != 0) {
this._output.write(" s=\"" + cellStyle.getIndex() + "\"");
}
this._output.write(" t=\"inlineStr\">");
this._output.write("<is>");
for(int i = 0; i < listElt.size(); i++) {
CTRElt elt = listElt.get(i);
if(elt.isSetRPr()) {
// the case of having font styles
this._output.write("<r>");
this._output.write("<rPr>");
// write rpr infomation, which CTRElt has (*)
this._output.write("</rPr>");
this._output.write("<t");
if(hasLeadingTrailingSpaces(elt.getT())) {
this._output.write(" xml:space=\"preserve\"");
}
this._output.write(">");
outputQuotedString(elt.getT());
this._output.write("</t>");
this._output.write("</r>");
}
}
this._output.write("</is>");
this._output.write("</c>");
}
}
(Sorry, some parts(*) are ommitted.)
-----------------------------------------
Is there any problems in my code?
If possible, I hope it would be reflected in next version.
Thanks,
--
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]