Hello,
i have to read an excel file wehere the format can be hssf or xssf,
so i chose SS to do the work.
Finaly i want so save the edited document as an xslx-excel-file.
Some cells have to be copied from the input file but i can't find
a way to xopy a RichTextString from HSSF to XSSF.
This is how i do it:
int type = cell.getCellType();
Cell targetCell = targetRow.createCell(index);
targetCell.setCellStyle(targetStyle);
CreationHelper createHelper = targetWorkbook.getCreationHelper();
switch (type) {
[..]
case Cell.CELL_TYPE_STRING :
targetCell.setCellValue(cell.getRichStringCellValue());
break;
[..]
}
This only works if the input is an xssf-file, otherwise i get:
java.lang.ClassCastException:
org.apache.poi.hssf.usermodel.HSSFRichTextString
cannot be cast to org.apache.poi.xssf.usermodel.XSSFRichTextString
at org.apache.poi.xssf.usermodel.XSSFCell.setCellValue
(XSSFCell.java:343)
and the only solution i see, is to copy only the string text
without any formatting.
Is there any solution?
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]